想实现,选定下拉框1大类后,下拉框2筛选出对就大类的小类,目前是用
<select name="zcdl" onchange="selectsteelkind()">
         <option value="00" selected>请选择大类</option>   中的onchage实现
function selectsteelkind(){
  document.form1.action="aa.jsp?index=3";
  document.form1.submit();
}
其中aa.jsp是本页面,但aa.jsp还有其它项,下拉框功能实现后其它的项也跟着刷新了,录入的其它项就没有了,如何改
成只提交下拉框项其它项不动。

解决方案 »

  1.   

    用到级联   一个小例子  
    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=gb2312">
    <TITLE>级联显示</TITLE>
    <SCRIPT type="text/javascript">
    function showType(party){
    var arttype = new Array();
    arttype[0] = ["人类","暗夜精灵","矮人","侏儒"];
    arttype[1] = ["兽人","牛头人","亡灵","巨魔"];
    if(party!=0){
    document.myform.artTarget.options.length=0;
    for(var i in arttype[party-1]){
    document.myform.artTarget.options.add(new Option(arttype[party-1][i],parseInt(i)+1))
    }
    document.myform.artTarget.options.selectedIndex=0;
    showPic(1)
    }
    }
    function showPic(num){
    var type=document.myform.artParty.value;
    if(type==1){
    for(var i=1;i<5;i++){
    if(num==i){
    document.getElementById("lm"+i).style.display="block";
    }else{
      document.getElementById("lm"+i).style.display="none";
    }
    document.getElementById("bl"+i).style.display="none";
    }
    }else if(type==2){
    for(var i=1;i<5;i++){
    if(num==i){
    document.getElementById("bl"+i).style.display="block";
    }else{
    document.getElementById("bl"+i).style.display="none";
    }
    document.getElementById("lm"+i).style.display="none";
    }
    }
    }
    </SCRIPT>
    <STYLE type="text/css">
    td{font-size:14px; font-family:"宋体"; font-weight:bold}
    </STYLE>
    </HEAD><BODY>
    <FORM action="" method="post" name="myform">
    <TABLE width="666" cellpadding="0" cellspacing="0" background="images/bg.jpg" align="center">
      <TR>
        <TD  height="70" align="center"><H3>魔兽世界八大种族(图)</H3></TD>
      </TR>
      <TR>
      <TD align="center">阵营选择
       <SELECT name="artParty" onChange="showType(this.selectedIndex)" style="width:140px">
      <OPTION value="">--请选择你的阵营--</OPTION>
      <OPTION value="1">联盟</OPTION>
      <OPTION value="2">部落</OPTION>
    </SELECT>
      </TD>
      </TR>
      <TR>
        <TD height="44" align="center">角色选择
    <SELECT name="artTarget" onChange="showPic(this.value)" style="width:140px">
      <OPTION value="">--请选择一个种族--</OPTION>
    </SELECT>
    </TD>
      </TR>
      <TR>
        <TD align="center" height="234">
    <DIV id="lm1" style="display:none"><IMG src="images/humans-small.jpg"></DIV>
        <DIV id="lm4" style="display:none"><IMG src="images/gnomes-small.jpg"></DIV>
        <DIV id="lm3" style="display:none"><IMG src="images/dwarves-small.jpg"></DIV>
        <DIV id="lm2" style="display:none"><IMG src="images/nightelves-small.jpg"></DIV>
        <DIV id="bl1" style="display:none"><IMG src="images/orcs-small.jpg"></DIV>
        <DIV id="bl2" style="display:none"><IMG src="images/tauren-small.jpg"></DIV>
    <DIV id="bl3" style="display:none"><IMG src="images/undead-small.jpg"></DIV>
    <DIV id="bl4" style="display:none"><IMG src="images/trolls-small.jpg"></DIV></TD>
      </TR>
    </TABLE></FORM>
    </BODY>
    </HTML>
      

  2.   

    我现在下拉框联动是实现了,但因为调用了aa.jsp所以其它录入项值被刷新了,所就这个改动
      

  3.   

    原代码
    <td width="77" height="41" align="right"><span class="style14">资产名称</span></td>
                  <td width="218" align="left"><input type="text" name="selzcmc" class="style28" id="selzcmc2" size="28" align="left"/></td>
               <td height="39" align="right" class="style14">资产类型</td>
    //////////////////
    <td colspan="2"><p align="center"><select name="zcdl" onchange="selectsteelkind(){
    ">
             <option value="00" selected>请选择大类</option>
    <%
    String id1=request.getParameter("zcdl");
    if(id1==null){
      id1="00";
    }
    try{
      con=common.ConnectDataBase.getConnection();
      stmt=con.createStatement();
      String sql="select distinct dlbm ,dlmc from sb_zcdl ";//连接一期数据库
      ResultSet rs=stmt.executeQuery(sql);
      while(rs.next()){
        String firstid=rs.getString("dlbm");
        String firstname=rs.getString("dlmc");
    %>
         <option value="<%=firstid%>" <%=firstid.equals(id1)?"selected":"" %>><%=firstname%></option>
    <%
      }
      rs.close();
    }
    catch(Exception e){
      e.printStackTrace();
    }
    finally {
      try { stmt.close();   }
      catch (Exception e) { e.printStackTrace(); }
      try {  con.close();   }
      catch (Exception e) { e.printStackTrace(); }
    }
    %>
          </select></td>
      <td colspan="2"><p align="center"><select name="zclx">
                <option value="00" selected>请选择小类</option>
    <%try{
      con=common.ConnectDataBase.getConnection();
      stmt=con.createStatement();
      System.out.println(id1);
      String sql="select  zclxmc,zclxbm from sb_zclx where zclxbm like '"+id1.trim()+"%'";
      System.out.println(sql);
      ResultSet rs=stmt.executeQuery(sql);
      while(rs.next()){
        thirdid=rs.getString("zclxbm");
        thirdname=rs.getString("zclxmc");
    %>
         <option value="<%=thirdid%>"><%=thirdname%></option>
    <%
      }
      rs.close();
    }
    catch(Exception e){
      e.printStackTrace();
    }
    finally {
      try { stmt.close();   }
      catch (Exception e) { e.printStackTrace(); }
      try {  con.close();   }
      catch (Exception e) { e.printStackTrace(); }
    }
    %>
    </select></td>
    ////////////////
    function selectsteelkind(){
      document.form1.action="aa.jsp?index=3";
      document.form1.submit();
    }
    下拉框联动做到了,但先前录入的资产名称项值没了,如何改