选择出现下拉框

1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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));
        }
    }

 

 

 

转载于:https://my.oschina.net/u/875636/blog/92948

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值