http://sz.luohuedu.net/xml/exam/multiselect.asp源代码请发mail

解决方案 »

  1.   

    你传时候用onchange="change_java(this.value)" 将当前选中的值传到一个函数中,搜索下一级的列表,找到以后付给一个数组,然后再用你的下拉列表构建函数!
      

  2.   

    就是这个,其中的left呀right函数都不能用,警告什么非法操作,不知道为什么
    <html> 
    <head> 
    <title>List</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    <% 
    dim conn 
    dim rs 
    dim sql 
    dim count 
    dim rs1 
    dim sql1 
    dim rs2 
    dim sql2 
    dim count2
    dim mycount1
    dim mycount2 %>
    <%set conn=server.createobject("ADODB.connection")
    cnnstring="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("district_code.mdb") 
    conn.open cnnstringsql = "select * from 行政区划代码 order by code_name" 
    set rs = conn.execute(sql) 
    %> 
    <script language = "JavaScript"> 
    var onecount; 
    onecount=0; 
    subcat = new Array(); 
    <% 
    count = 0 
    do while not rs.eof 
    %> 
    subcat[<%=count%>] = new Array("<%=trim(rs("code_name"))%>");
    <% 
    count = count + 1 
    rs.movenext 
    loop 
    rs.close 
    set rs=nothing 
    %> 
    onecount=<%=count%>; 
    function changelocation0(locationid) 

    document.myform.smalllocation.length = 0; var locationid1=locationid;
    var condition1=locationid1.left(2);
    var i; 
    var subsub=new array();
    mycount1=0;
    document.myform.smalllocation.options[0] = new Option('==市==','');
    for(i=0;i<onecount-1;i++)

    number2=new string(locationid);
    number=new String(subcat[i]);
    number1=number.left(6);
    number1=number1.right(2);
    if((number.left(2)==number2.left(2))&&(number1=='00'))
    {
    mycount1=mycount1+1;
    subsub=array(subcat[i]);
    document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i],subcat[i]); 
    }

    }
    function changelocation(locationid) 
    {
    var abc=new string(locationid)
    alert(abc.substr(0,6)) 
    }
    </script> <script language=javascript>
    function changelocation2(villageid) 
    {
    document.myform.village.length = 0; 
    var villageid1=villageid; var j; 
    document.myform.village.options[0] = new Option('==所选地区的县区==',''); 
    for (j=0;j <mycount1-1; j++) 

    var number1=new string(subsub[i]);
    var number2=new string(villageid);
    sth1=number1.substr(0,4);
    sth2=number2.substr(0,4);
    if(sth1==sth2)
    {
    document.myform.village.options[document.myform.village.length] = new Option(subsub[i],subsub[i]);
    }

    }
    </script> </head> 
    <body> 
    <form name="myform" method="post"> 
    <!--题目:<input type="text" name="T2" size="20">来源:<input type="text" name="T3" size="20">-->分类:<select name="biglocation" onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].text)" size="1"> 
    <option selected>请选择省份</option> 
    <% sql1 = "select * from 行政区划代码 where code_name like '%0000%' order by code_name asc" 
    set rs1 = conn.Execute (sql1) 
    do while not rs1.eof 
    %> 
    <option value="<%=trim(rs1("code_name"))%>"><%=trim(rs1("code_name"))%></option> <% 
    rs1.movenext 
    loop 
    rs1.close 
    set rs1 = nothing 
    %> 
    </select><select name="smalllocation" onChange="changelocation2(document.myform.smalllocation.options[document.myform.smalllocation.selectedIndex].text)"> 
    <option selected value="">==市列表==</option> 
    </select><select name="village" size="1"> 
    <option selected>==县列表==</option> 
    </select> 
    <!--关键词:<input type="text" name="T4" size="20">内容:<textarea rows="9" name="S1" cols="51"></textarea> -->
    </form> </body> 
    </html>