0

Hey, I have a drop down box done in html and I'm just wondering if it would be possible to have 2 separate text boxes appear when a specific drop down item is selected. 所以

下拉菜单 - 第 1 项 - 第 2 项 - 第 3 项

如果选择了第 3 项,则

输入文本框 1 出现 - 输入文本框 2 出现

多谢你们

4

1 回答 1

2
<select id='combo'>
   <option>...</option>
</select>
<input  id='text1' style='display: none'/>
<input  id='text2' style='display: none'/>
<script>
// Disclaimer: using a library (jquery, ext-core, prototype) to bind events and change 
// styles is safer across browsers
document.getElementById('combo').onchange = function() {
  var display = this.selectedIndex == 2 ? "inline" : "none";
  document.getElementById('text1').style.display = display;
  document.getElementById('text2').style.display = display;
}
</script>
于 2011-01-27T22:55:44.297 回答