在页面上有两个select  <select name="channelType" id="channelType">
 <option value="nochannel">请选择</option>
 <option value="cctv">中央</option>
<option value="local">地方</option>
</select>一开始未选择的时候下面什么也不显示
如果选择了中央 就在下面显示一个中央台的所有频道的select这个该如何操作 谢谢

解决方案 »

  1.   

    这个用jquery +ajax 就可以实现
      

  2.   

    简单一点的话,可以把第二个select放在iframe里,第一个select的onexchange事件来控制第二个select的显示
      

  3.   

    用DWR 可以实现(级联),如果不想用DWR的话,用jquery也行, <select name="XX" id="XX" style="width:200px" change='chuxian(this);'>
    </select>
    然后chuxian这个函数用ajax调用后台方法,方法可以直接拼凑出  buffer.append("<option value='ALL'>ALL</option>");类似这种的,建议你去搜索一下“级联”。
      

  4.   

    静态的级联如下,如果要改成从后台用ajax取也很容易的<html>
    <head>
    <script type="text/javascript">
    function changeChannel(channelValue){
    var div = document.getElementById("channelDiv");
    if(channelValue =="nochannel"){
    div.innerHTML=""
    }else if(channelValue =="cctv"){
    var html="";
    html+="<select name=\"channel\">";
    html+="<option value=\"cctv1\">中央一套</option>";
    html+="<option value=\"cctv2\">中央二套</option>";
    html+="</select>";
    div.innerHTML=html;
    }else{
    var html="";
    html+="<select name=\"channel\">";
    html+="<option value=\"hbtv\">湖北卫视</option>";
    html+="<option value=\"hntv\">湖南卫视</option>";
    html+="</select>";
    div.innerHTML=html;
    }
    }
    </script>
    </head>
    <body>
    <select name="channelType" id="channelType" onchange="changeChannel(this.value)">
     <option value="nochannel">请选择</option>
     <option value="cctv">中央</option>
    <option value="local">地方</option>
    </select>
    <div id="channelDiv"></div>
    </body>
    </html>