第一个下拉列表框中有两个选项,选择不同的选项使第二个下拉框变的可用或是不可用这样的JS应该怎么写啊?

解决方案 »

  1.   

    document.getElementById("...").disabled=true;
    document.getElementById(".....").disabled=false;
      

  2.   

    if(document.form1.checkbox1.value="xxx"){
    document.form1.checkbox2.disabled=true;
    }
      

  3.   

    window.document.getElementById("name/id").disabled=false;
      

  4.   

    window.document.getElementById("name/id").disabled=true;
      

  5.   

    我之前是这么写的
    function gray() {
    var a = document.getElementById("restricted").value; if (a != 0) { document.all.terminalid.disabled = false;
    document.all.terminalid.style.backgroundColor = '#ffffff';

    } else {
    document.all.terminalid.disabled = true;
    document.all.terminalid.style.backgroundColor = '#cccccc';

    }
    }不过有问题,有时候得选择几次后才会产生输入框变灰的效果 ...
      

  6.   

    你用ALERT测试一下,看你是不是每次都触发了,还有就是你A的值看是什么
      

  7.   

    function changesel(csel){ var cselopetions = csel.options;
    var next = document.getElementById("operate");

    //alert('=====disable'+cselopetions.length);
    for(var i = 0; i<cselopetions.length ;i++){

    if("disable"==cselopetions[i].value&&cselopetions[i].selected){
    next.disabled=true;
    }
    if("enable"==cselopetions[i].value&&cselopetions[i].selected){
    next.disabled=false;
    }
    }
    } <select id="controlsel" onchange="changesel(this)">
    <option>select</option>
    <option value="enable" >enable</option>
    <option value="disable">disable</option>
    </select>
    <select id="operate">
    <option>aa</option>
    <option>bb</option>
    </select>
      

  8.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>无标题文档</title>
    <script type="text/javascript">
    function change(obj)
    {
    if(obj.value=="false")
    {
    document.getElementById("select2").disabled=true;
    }
    else
    {
    document.getElementById("select2").disabled=false;
    }
    }
    </script>
    </head><body>
    <select id="select1" onchange="change(this)" >
    <option value="true">true</option>
    <option value="false">false</option>

    </select><select id="select2" >

    </select>
    </body>
    </html>