webform2.aspx <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb" Inherits="salonmaster.WebForm2"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <script language="javascript"> //jb函数会根据不同的浏览器初始化个xmlhttp对象 function jb() { var A=null; try { A=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { A=new ActiveXObject("Microsoft.XMLHTTP"); } catch(oc) { A=null } } if ( !A && typeof XMLHttpRequest != "undefined" ) { A=new XMLHttpRequest() } return A } //下面Go函数是父列表框改变的时候调用,参数是选择的条目 function Go(obj) { //得到选择框的下拉列表的value var svalue = obj.value; //定义要处理数据的页面 var weburl = "webform2.aspx?parent_id="+svalue; //初始化个xmlhttp对象 var xmlhttp = jb(); //提交数据,第一个参数最好为get,第三个参数最好为true xmlhttp.open("get",weburl,true); // alert(xmlhttp.responseText); //如果已经成功的返回了数据 xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4)//4代表成功返回数据 { var result = xmlhttp.responseText;//得到服务器返回的数据 //先清空dListChild的所有下拉项 document.getElementById("dListChild").length = 0; //给dListChild加个全部型号的,注意是Option不是option document.getElementById("dListChild").options.add(new Option("所有城市","0")); if(result!="")//如果返回的数据不是空 { //把收到的字符串按照,分割成数组 var allArray = result.split(","); //循环这个数组,注意是从1开始,因为收到的字符串第一个字符是,号,所以分割后第一个数组为空 for(var i=1;i<allArray.length;i++) { //在把这个字符串按照|分割成数组 var thisArray = allArray[i].split("|"); //为dListChild添加条目 document.getElementById("dListChild").options.add(new Option(thisArray[1].toString(),thisArray[0].toString())); } } } } //发送数据,请注意顺序和参数,参数一定为null或者"" xmlhttp.send(null); } </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:dropdownlist id="dListParent" style="Z-INDEX: 101; LEFT: 160px; POSITION: absolute; TOP: 56px" runat="server" onchange="Go(this)"> </asp:dropdownlist> <asp:dropdownlist id="dListChild" style="Z-INDEX: 102; LEFT: 304px; POSITION: absolute; TOP: 56px" runat="server"></asp:dropdownlist><asp:button id="Button1" style="Z-INDEX: 103; LEFT: 176px; POSITION: absolute; TOP: 128px" runat="server" Text="提交"></asp:button> <asp:Label id="Label1" style="Z-INDEX: 104; LEFT: 168px; POSITION: absolute; TOP: 24px" runat="server">Label</asp:Label> </form> </body></HTML> 后台代码 Imports System.Data.OleDb 呵呵...参考C#联动的.附加上个数据库...不过还没有写三级联运呢.. 相关文章: 2022-12-23 2021-10-15 2021-09-30 2022-12-23 2022-12-23 2022-12-23 2021-11-29