我现在有2个表
我要做的是就把第一个列表框选择的AA表ID字段等于BB表KK字段的值,显示在第2个列表框里
AA表                  BB表
ID    RR              ID     GG        KK
1    EEEEE            1      EETTT      1
2    FFFF             2      JJAAA      2
3    LLLL             3     HHHHH       2
4    AAAAA            4     HHTTT       1<TD><select name="selectm" id="select">
                                 <option value="">请选择</option>
<%
               rs=p_dbBean.executeQuery("select * from  aa");
   while (rs.next())
   {
%>
    <option value="<%=rs.getString("id")%>"><%=rs.getString("RR")%></option>

                            
<%
   }
%> 
</select>
    </TD>
<%
   // mm=request.getParameter("id");
  //System.out.println(mm);
%> <td><select name="selectm1" id="select1">
      <option value="">请选择</option>
        <%
               rs1=p_dbBean.executeQuery("select * from  bb  where tt=' " + mm + " ' ");
   while (rs1.next())
   {
%>
    <option value="<%=rs1.getString("KK")%>"><%=rs1.getString("gg")%></option>
  <%
}
  %>
</select></td>

解决方案 »

  1.   

    s.jsp
    -------------------------------
    <form action="s1.jsp" target="s1" method="post">
    <input type="hidden" name="id" >
    </form>
    <select name="selectm" id="select" onchange="document.forms[0].elements[0].value=this.value;document.forms[0].submit();">
                                     <option value="">请选择</option>
    <%
                   rs=p_dbBean.executeQuery("select * from  aa");
       while (rs.next())
       {
    %>
        <option value="<%=rs.getString("id")%>"><%=rs.getString("RR")%></option>

                                
    <%
       }
    %> 
    </select><iframe src="s1.jsp" name="s1"/>
    s1.jsp
    ------------
    <%
    mm=request.getParameter("id");%>
    <select name="selectm1" id="select1">
          <option value="">请选择</option>
            <%
                   rs1=p_dbBean.executeQuery("select * from  bb  where tt=' " + mm + " ' ");
       while (rs1.next())
       {
    %>
        <option value="<%=rs1.getString("KK")%>"><%=rs1.getString("gg")%></option>
      <%
    }
      %>
    </select>