我有一个分支下拉效果(不确定名称)。我不擅长 javascript 和 jquery,但我可以修改很少。有了这些知识,我制作了这个效果。
你可以看到现场演示:http ://saifraihan.webege.com/Branching%20New/branching.html
这是我的:
HTML
<form id="survey" action="#" method="post">
<div id="section">
<label for="Select">Select a step</label>
<select id="select" onchange="selection(this);">
<option value="none">
Input1
</option>
<option value="radio">
Radio1
</option>
</select>
</div>
<div id="section2" style="display:none;">
<input name="" type="text">
</div>
<div id="section5" style="display:none;">
<p>
Radio Step 1<br/>
<label>
<input type="radio" name="RadioGroup2" value="radio" id="RadioGroup2_0">
Radio</label>
<br>
<label>
<input type="radio" name="RadioGroup2" value="radio" id="RadioGroup2_1">
Radio</label>
<br>
</p>
</div>
</form>
JS:
var sections ={
'none': 'section2',
'radio': 'section5'
};
var selection = function(select) {
for(i in sections)
document.getElementById(sections[i]).style.display = "none";
document.getElementById(sections[select.value]).style.display = "block";
}
此示例在 FF、Chrome 和 Opera 中运行良好。但问题是,它不适用于任何版本的 IE。我不知道为什么。由于我在 javascripts 方面很弱,我不知道为什么这不在 IE 中运行。有什么解决办法吗?如果可以,它会很棒。
提前致谢 。