用ONCHANGE提交表单,取得查询条件,把查询结果输出在第二个列表框;
不够这样每次都得提交

解决方案 »

  1.   

    哪位能用javascript把版主的问题实现
      

  2.   

    参考一下!
    <html><head><script>
    function check()
    {
      if(f1.d1.options[0].selected)
      {
         f1.d2.length=0     f1.d2.options.add(new Option("白菜","白菜"))
         f1.d2.options.add(new Option("萝卜","萝卜"))
      
      }
      else if(f1.d1.options[1].selected)
      {
         f1.d2.length=0
         f1.d2.options.add(new Option("苹果","苹果"))
         f1.d2.options.add(new Option("桃","桃"))  }}
    </script>
    </head><body><form name="f1" method="POST" action="--WEBBOT-SELF--">
      
      <p><select size="1" name="d1" onchange="check()">
        <option>蔬菜</option>
        <option>水果</option>
      </select><select size="1" name="d2">
      </select></p>
    </form></body></html>
      

  3.   

    类似csdn的菜单,在你的第一个Select中的OnChange事件里使用xmlhttp提交,然后使用xmlDom将查询结果load(xml格式)到第二个Select中,也可以直接处理字符串形式的responseBody
      

  4.   

    以前帮别人写的一段代码
    用XML,就是wangyiyun0119(wangyy) 说的原理============================
    <html>
    <head>
    <title>New Page 2</title>
    </head>
    <body bgcolor="#F4FAFF" leftmargin="0">
    <%
    strPathInfo = Request.ServerVariables("PATH_INFO")
    strPathInfo = "http://" & Request.ServerVariables("SERVER_NAME") & Left(strPathInfo,InstrRev(strPathInfo,"/"))
    %>
    <%
    '================================================================
    '这里是我的连接数据库的代码,你把他换成你的就行了
    Dim fcpdb, rs,sqlstr
    Set fcpdb=server.createobject("adodb.connection")
    fcpdb.CursorLocation=3
    fcpdb.open "dsn=test;uid=sa;pwd=;"
    '================================================================
    %>
    <form method="post" target="mn" action="result.asp" name=form >
      
      <p align="center"> 
        <select size="1" name="D2" onchange="javascript:change(this,form.D1)">
      <%  
        sqlstr="select a.b_name b_name,b.b_code b_code from rsv_code a,rsv_cdr b where a.stcd=b.stcd"
        Set rs=fcpdb.execute(sqlstr)
        If Not rs.eof And Not rs.bof Then                           
        rs.movefirst
      While Not rs.EOF
    %>        
    <option value="<%=rs("b_code")%>"><%=TRIM(rs("b_name"))%></option>      
      <% 
       rs.MoveNext              
    Wend
      End If 
       %>
    </select>
        <select size="1" name="D1">
      </select>
        &nbsp;
    </form>  
    <Script LANGUAGE="JavaScript">                                   
    function change(source,target)
    { if(source.options(source.selectedIndex).value=="")
    return;
      target.innerHTML=""
    var url = '<%=strPathInfo%>XML_Data.asp?b_code=' + source.options(source.selectedIndex).value; //这里传递条件到 XML_Data.asp,XML_Data.asp生成XML的查询结果         
      var oXMLDoc =  new ActiveXObject('MSXML');
    oXMLDoc.url = url;

      var oRoot=oXMLDoc.root;
      if(oRoot.children != null)
      {
    for(var i=0;i<oRoot.children.length;++i)
        {
    oItem = oRoot.children.item(i);
          sName = oItem.text;
          sValue = oItem.getAttribute("id");
          var oOption = document.createElement('OPTION');
          oOption.text = sName;
          oOption.value = sValue;
          target.options.add(oOption);
        }
      }
    }
    window.attachEvent("onload",new Function("change(form.D2,form.D1)"))
    </Script>
    </body>   
        
    </html>    
    XML_Data.asp
    =================================
    <?xml version="1.0" encoding="gb2312" ?>
    <St_code_as>
    <%
    Dim fcpdb, rs,sqlstr,b_code 
    Set fcpdb=server.createobject("adodb.connection")
    fcpdb.CursorLocation=3
    fcpdb.open "dsn=test;uid=sa;pwd=;"
    b_code = Request("b_code")
    sqlstr = "select c.stcd stcd,c.hs_name hs_name from rst_code a,St_cdr b,St_code_a c,St_code_b d where a.hs_code=b.hs_code and b.stcd=c.stcd and c.stcd=d.stcd and d.hs_type='F' and a.b_code=" & b_code
    Set rs=fcpdb.execute(sqlstr)
    If Not rs.eof And Not rs.bof Then                           
    rs.MoveFirst
    While Not rs.eof
    %>
    <St_code_as id="<%=rs("stcd")%>"><%=rs("hs_name")%></St_code_as>
    <%
    rs.MoveNext
    Wend
    Else
    %>
    <St_code_as id="无数据">无数据</St_code_as>
    <%
    End If
    %>
    </St_code_as>
      

  5.   

    对阿
    用xmlhttp就不用刷新页面了
      

  6.   

    用重载script标签的src属性就可以
      

  7.   

    http://www.wy1997.com/sailflying/learn/CitySelect.htm包括实例和讲解你可以把数据一次输入为XML文件