Ajax| pull Down
I've finally had time to study Ajax recently. Read some Ajax introductions.
Use the prototype framework to complete a dropdown box (asp:dropdownlist) linkage of the Ajax small example, and beginners to share.
Code download
<script language= "javascript" type= "Text/javascript" >
<!--
function gocity ()
{
var url = "Areahandler.ashx";
var father= $F (' <%=ddlProvince.ClientID%> ')
var pars = "ddl=province&father=" +father;
var myajax = new Ajax.request (
Url
{method: ' Get ', Parameters:pars, oncomplete:loadcity}
);
}
function Goarea ()
{
var url = "Areahandler.ashx";
var father= $F (' <%=ddlCity.ClientID%> ')
var pars = "ddl=city&father=" +father;
var myajax = new Ajax.request (
Url
{method: ' Get ', Parameters:pars, Oncomplete:loadarea}
);
}
function Loadcity (originalrequest)
{
var Result=originalrequest.responsetext;
var ddl=$ (' <%=ddlCity.ClientID%> ')
Filldropdown (Ddl,result);
if (Ddl.length = = 0) {
$ (' <%=ddlArea.ClientID%> '). length=0;
$ (' <%=ddlArea.ClientID%> '). Disabled = 1;
ddl.disabled = ' true ';
}
else{
$ (' <%=ddlArea.ClientID%> '). Disabled = 0;
ddl.disabled = 0;
Goarea ();
}
}
function LoadArea (originalrequest)
{
var Result=originalrequest.responsetext;
var ddl=$ (' <%=ddlArea.ClientID%> ')
Filldropdown (Ddl,result);
if (ddl.length = 0)
ddl.disabled = 1;
Esle
ddl.disabled = 0;
}
function Filldropdown (objddl,result) {
var Piarray = Result.split (",");
objddl.length=0;
for (Var i=0;i<piarray.length;i++)
{
var ary1 = piarray[i].tostring (). Split ("|");
if (Ary1.length >1)
ObjDDL.options.add (New Option (Ary1[1].tostring (), ary1[0].tostring ()));
}
}
-->
</script>
Http://www.cnblogs.com/rippleyong/archive/2006/12/18/596015.html