An AJAX example of a drop-down box (asp:dropdownlist) linkage that was completed using the prototype framework

Source: Internet
Author: User
Tags split tostring
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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.