Ajax中通过一个dropdownlist控件的值给另一个dropdownlist控件赋值
比如说,dropdownlist1里面的值为大类的名称,如何通过选择dropdownlist1里面大类的名称,在dropdownlist2里面显示相应的大类下的 小类 的名称~~~~
哪位大虾帮帮忙,把代码发一下,谢谢啊,发我邮箱也可以:yzhwd521@sina.com~~~
万分感谢昂~~~
------解决方案--------------------default.aspx
-------------
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default "%>
<%@ Register Assembly= "System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 " Namespace= "System.Web.UI " TagPrefix= "asp " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<%@ Register TagPrefix= "uc1 " TagName= "show " Src= "~/WebUserControl.ascx " %>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Page </title>
<script language= "javascript " type= "text/javascript ">
function XmlPost(obj)
{
var svalue = obj.value;
if(svalue== "请选择 ")
{
document.all( "ddlInfo ").length=0;
}
else
{
var webFileUrl = "Default2.aspx?TypeID= " + svalue;
var result = " ";
var xmlHttp = new ActiveXObject( "MSXML2.XMLHTTP ");
xmlHttp.open( "POST ", webFileUrl, false);//使用XMLPOST方式
xmlHttp.send( " ");//发送
result = xmlHttp.responseText;//得到返回的结果
alert(result);
if(result != " ")
{
document.all( "ddlInfo ").length=0;//清空原来存在的
var piArray = result.split( ", ");
for(var i=0;i <piArray.length;i++)
{
var ary1 = piArray[i].toString().split( "| ");
document.all( "ddlInfo ").options.add(new Option(ary1[0].toString(),ary1[1].toString()));
}
}
else
{
alert(result);
}
}
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<asp:DropDownList ID= "ddlType " runat= "server "> </asp:DropDownList>
<asp:DropDownList ID= "ddlInfo " runat= "server ">
</asp:DropDownList>
</form>
</body>
</html>