我基本上想要例如用户选择"选项1"和"选项a"显示一件事,如果用户选择"选项2"和"选项c"显示另一个......等等。
我试图在https://jsfiddle.net/xw6t3gL4/8/
上玩它谢谢!
$('#first').on('change', function() {
if (this.value === "01") {
$("#one").show();
} else {
$("#one").hide();
}
});
$('#second').on('change', function() {
if (this.value === "a") {
$("#one").show();
} else {
$("#one").hide();
}
});

p {
display: none;
}

<div data-role="fieldgroup">
<select id="first">
<option>ONE</option>
<option value="01">Option 1</option>
<option value="02">Option 2</option>
<option value="03">"Option 3</option>
</select>
</div>
<div data-role="fieldgroup">
<select id="second">
<option>TWO</option>
<option value="a">Option a</option>
<option value="b">Option b</option>
<option value="c">Option c</option>
</select>
</div>
<p id="one">
1
</p>
<p id="two">
2
</p>
<p id="three">
3
</p>
&#13;
答案 0 :(得分:1)
这个怎么样?
$('select').on('change', function(){
var select1 = $('#first').val();
var select2 = $('#second').val();
$('#one, #two, #three').hide();
if (select1 === "01" && select2 === "a") {
$('#one').show();
}
if (select1 === "02" && select2 === "b") {
$('#two').show();
}
if (select1 === "03" && select2 === "c") {
$('#three').show();
}
});
答案 1 :(得分:0)
您可以使用switch()
来评估所选值。
答案 2 :(得分:0)
尝试使用输入值更新单个div的内容。 https://jsfiddle.net/xw6t3gL4/9/
您还可以根据值,让PHP处理值并输出您希望的结果:
$('#output').load('process_page.php?input1=' + $("#first").val() + '&input2=' + $("#second").val());