我希望的是让option1选A值时候,option2下拉菜单就不能选B值,用AND将这两句连起来没有效果,麻烦达人指点一下,谢谢先~
if(document.form.option1.value=='A' AND document.form.option2.value=='B'){
 alert("请检查option1和option2的选项!");
 document.form.option2.focus();
 return false;
}
}

解决方案 »

  1.   

    document.form.option1.value=='A' AND document.form.option2.value=='B'
    ==>
    document.form.option1.value=='A' && document.form.option2.value=='B'
      

  2.   

    回LtnRain达人,这样不行,没有用
    同时(IE6)页面左下角显示!感叹号说有错
      

  3.   


    var osel = document.getElementById('selectId');
    var osel2 = document.getElementById('select2Id');
    var oindex = osel.options[osel.selectedIndex].value;
    var oindex2 = osel2.options[osel2.selectedIndex].value;
    if(oindex == 'A' && oindex2 == 'B')
      

  4.   

    if(document.getElementById("option1").value=='A' && document.getElementById("option2").value=='B'){
             alert("请检查option1和option2的选项!");
             document.getElementById("option2").focus();
             return false;
        }
      

  5.   

    你换个想法哈,当option1选择A的时候,你就把option2里面的B给删除不就行了吗
      

  6.   

    各位达人,我的代码是这样的,没有效果<html>  
    <head>  
    <title>test</title>  
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <script LANGUAGE="javascript">
    if(document.getElementById("option1").value=='A' && document.getElementById("option2").value=='B'){
            alert("请检查option1和option2的选项!");
            document.getElementById("option2").focus();
            return false;
        } 
    </script> <form action="e.php" method="POST" name="form"> <select name="option1">
    <option>A</option>
    <option>C</option>
    </select>

    <select name="option2">
    <option>B</option>
    <option>D</option>
    </select>

    <input type="submit" name="submit" value="submit"></input>

    </form></body>
    </html>
      

  7.   

    大哥,你上面肯定不行啦<html>  
    <head>  
    <title>test</title>  
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <script LANGUAGE="javascript">
    function check(selfObj){
    var a = document.getElementById('option1')  ;
    var b = document.getElementById('option2') ;

    if(a.options[a.selectedIndex].text=='A' && b.options[b.selectedIndex].text=='B'){
            alert("请检查option1和option2的选项!");
            selfObj.selectedIndex = 0 ;
        } 
    }
        
    </script>    <form action="e.php" method="POST" name="form">    <select id="option1" name="option1" onchange="check(this)">
    <option>-=请选择=-</option>
            <option>A</option>
            <option>C</option>
        </select>
        
        <select id="option2" name="option2" onchange="check(this)">
    <option>-=请选择=-</option>
            <option>B</option>
            <option>D</option>        
        </select>
        
        <input type="submit" name="submit" value="submit"></input>
        
    </form></body>
    </html>