我有一张选择项的表单,里面有:北京,上海,天津,重庆等选项,亦有三个隐藏了的输入框(输入),想问如何在选取了北京之后可以把这三个隐藏了的输入框显示出来?而选取上海,天津,重庆的时候则不用显示。谢谢!

解决方案 »

  1.   

    <BODY>
      <select id="sele" OnChange="ff()">
      <option value="1">北京
      <option value="2">上海
      </select>
      <input type="text" size="10" id="txt1">
      <input type="text" size="10" id="txt2">
     </BODY>
    </HTML>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function ff()
    {
    if (document.all.sele.selectedIndex == 0)
    {
    document.all.txt1.style.display = ""
    document.all.txt2.style.display = ""
    }
    else
    {
    document.all.txt1.style.display = "none"
    document.all.txt2.style.display = "none"
    }
    }
    //-->
    </SCRIPT>
      

  2.   

    <select onchange="show(this)">
    <option value="北京">....
    <div id="data" style="display:none"><input></div>
    function show(x)
    {
    if(x.options[x.selectedIndex].value=="北京")
    {
    document.getElementById("data").style.display=""
    }
    else
    {document.getElementById("data").style.display="none"
    }
    }
      

  3.   

    LS说得没错,1,2L都讲完了
    不过你相了解具体一点的话自己去搜“级联菜单”看吧
      

  4.   

    <select onchange="show(this.value)">
    <option value="2">隐藏</option>
    <option value="1">显示</option>
    </select>
    <input id="a" style="display:none;">
    <script type="text/javascript">
    function show(t){
    if(t==1)
    {
     document.getElementById("a").style.display = "block";
     document.getElementById("a").value = "";
    }
    else
    {
     document.getElementById("a").style.display = "none";
    }}
    </script>