<html xmlns=" http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function change(){
var index = document.getElementById('s1').selectedIndex;
if(index==2){
document.getElementById('s2').style.display="";
}else{ document.getElementById('s2').style.display="none"; }
}
</script>
</head>
<body>
<table width="400" border="1"> <tr>
<td>一级下拉框</td>
<td>
<select id="s1" style="width:200px" οnchange="change()">
<option>--请选择--</option>
<option>无二级下拉框</option>
<option>有二级下拉框</option>
</select> </td>
</tr>
<tr id="s2" style="display:none">
<td>二级下拉框</td>
<td>
<select id="" style="width:200px">
<option>--请选择--</option>
<option>1</option>
<option>2</option>
</select>
</td>
</tr>
</table>
</body>
</html>
2.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
第一个下拉
<td width="126">
<select name="searchFirst" id="searchFirst" οnchange="selectChange()">
<option name="searchmaxid" value="-1">--请选择--</option>
<c:forEach items="${requestScope.mcType}" var="first">
<c:if test="${first.npid==0}">
<option name="smaxid" value="${first.nid}">${first.sname }</option>
</c:if>
</c:forEach>
</select></td>
第二个下拉
<td width="95">
<select name="searchSecond" value="${param.searchSecond}">
<option name="serachminid" value="-1">--请选择--</option>
</select>
</td>
方法:function selectChange(){
var second_npid=document.getElementById("searchSecond");
searchForm.searchSecond.options.length=1;
var first_nid=document.getElementById("searchFirst").value;
for(i=0;i<${j};i++){
if(array_2[i].npid==first_nid){
searchForm.searchSecond.options.add(new Option(array_2[i].sname,array_2[i].nid));
}
}
|