在页面上有两个select <select name="channelType" id="channelType">
<option value="nochannel">请选择</option>
<option value="cctv">中央</option>
<option value="local">地方</option>
</select>一开始未选择的时候下面什么也不显示
如果选择了中央 就在下面显示一个中央台的所有频道的select这个该如何操作 谢谢
<option value="nochannel">请选择</option>
<option value="cctv">中央</option>
<option value="local">地方</option>
</select>一开始未选择的时候下面什么也不显示
如果选择了中央 就在下面显示一个中央台的所有频道的select这个该如何操作 谢谢
</select>
然后chuxian这个函数用ajax调用后台方法,方法可以直接拼凑出 buffer.append("<option value='ALL'>ALL</option>");类似这种的,建议你去搜索一下“级联”。
<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>