嗨,我有主列表框,它包含一个 3 值,所以如果我选择了第一个值,它必须显示一个文本,然后我再次选择了第二个值,它必须显示列表框 ..同样明智,我尝试过但没有结果
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.hidden
{
display: none;
}
</style>
<script>
function getValue()
{
var x=document.getElementById("sel");
var A=document.getElementById("a");
var B=document.getElementById("b");
var C=document.getElementById("c");
for (var i = 0; i < x.options.length; i++)
{
if(x.options[i].selected ==true)
{
if(x.options[i].value == "volvo")
{
A.style.display = 'block';
B.style.display = 'none';
C.style.display = 'none';
}
if(x.options[i].value == "Saab")
{
A.style.display = 'block';
B.style.display = 'none';
C.style.display = 'none';
}
if(x.options[i].value == "Opel")
{
A.style.display = 'none';
B.style.display = 'none';
C.style.display = 'block';
}
}
}
}
</script>
</head>
<body>
<select id="sel" onClick='getValue()'>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
</select>
<div id="a" class="hidden">
APPLE,Mango
</div>
<div id="b" class="hidden">
<select>
<option name="m">2</option>
<option name="n">2</option>
</select>
</div>
<div id="c" class="hidden">
<select>
<option name="e">3</option>
<option name="f">3</option>
</select>
<select>
<option name="i">4</option>
<option name="j">4</option>
</select>
</div>
</body>
</html>