错误的提示是什么?
查看你生成的JS数据,value是什么,是否真的是"网络",加trim试试,我这试过都是好的

解决方案 »

  1.   

    不知是不是你要的
    <html>
    <head>
    <title></title>
    </head>
    <SCRIPT language="javascript" >
    var optionNum = "";
    var hospitalList = new Array("","水果","肉类");
    var roomList = new Array( ); 
    roomList[0] = new Array("请选择类别");
    roomList[1] = new Array("苹果","梨","香蕉");
    roomList[2] = new Array("猪肉","牛肉","鸡肉==你敢吃么??");
    function initSelect1()
    {
    while ( document.all.hospital.options.length > 0)
    hospital.options.remove(0);
    for (var i = 0; i < hospitalList.length; i++)
    {
    var opt = document.createElement("OPTION");
    opt.value = hospitalList[i];
    opt.text = hospitalList[i];
    document.all.hospital.options.add(opt);
    opt = null;
    }
    initSelect2();
    document.all.hospital.onchange = initSelect2;
    }function initSelect2()
    {
    while (document.all.room.options.length > 0)
    document.all.room.options.remove(0);
    var myArr = roomList[document.all.hospital.selectedIndex];
    for (var i = 0; i < myArr.length; i++)
    {
    var opt = document.createElement("OPTION");
    opt.text = myArr[i];
    opt.value = myArr[i];
    document.all.room.options.add(opt);
    opt = null;
    }
        var optionNum = document.all.hospital.selectedIndex;
    }
    function window.onload()
    {
    initSelect1(document.all.hospital);
    }
    function IndexDemo(str2){
       var str1 = "BABEBIBOB.UBABEBIBOBU"
       var s = str1.indexOf(str2);
       alert(s);
    }</SCRIPT>
    <body>
    <p>
      <select name= "hospital" id = "hospital" style="width:100px"> 
      </select>  
      <Select id = "room" style="width:200">
      </Select> 
      连动select菜单:
    </p>
    <p>&nbsp;</p>
    <form name="form1" method="post" action="">
      <p>&nbsp;</p>
      <p>
        <input type="submit" name="Submit" value="连动select菜单" onClick="IndexDemo(this)">
      </p>
    </form>
    <p>&nbsp;</p>
    </body>
    </html>