ajax无刷新省市区三级联动菜单

来源:互联网  作者:本站整理
摘要:1、GetCity.aspx?pid=private void Page_Load(object sender, System.EventArgs e)// 在此处放置用户代码以初始化页面Regex re=new Regex("^[0-9]……

function onC()
{
if (req.readyState == 4) {
if (req.status == 200) {
rC(req.responseText);              
} else {
alert('该请求有错误!');
}
}
}

function rC(x)
{
var doc = req.responseXML;
doc.loadXML(x);
var a = doc.getElementsByTagName("city");
for(var i= 0;i<a.length;i++)
{
document.all("ctl_loaded_ddlCity").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[0].text));
//document.all("SearchCZInfo1_ddlCity").options.add(new Option("a","a"));
}
}

function onZ()
{
if (req.readyState == 4) {
if (req.status == 200) {
rZ(req.responseText);              
} else {
alert('该请求有错误!');
}
}
}

function rZ(x)
{
var doc = req.responseXML;
doc.loadXML(x);
var a = doc.getElementsByTagName("zone");
for(var i= 0;i<a.length;i++)
{
document.all("ctl_loaded_ddlZone").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[0].text));
}
}

function onI()
{
if (req.readyState == 4) {
if (req.status == 200) {
rI(req.responseText);              
} else {
alert('该请求有错误!');
}
}
}

function rI(x)
{
var doc = req.responseXML;
doc.loadXML(x);
var a = doc.getElementsByTagName("images");
for(var i= 0;i<a.length;i++)
{
document.all("ctl_loaded_ddlPosition").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));
document.all("ctl_loaded_ddlFrame").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));
document.all("ctl_loaded_ddlPic1").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));
document.all("ctl_loaded_ddlPic2").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));
document.all("ctl_loaded_ddlPic3").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));
document.all("ctl_loaded_ddlPic4").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));
document.all("ctl_loaded_ddlPic5").options.add(new Option(a.item(i).childNodes[0].text,a.item(i).childNodes[1].text));

document.all("imgPosition").style.display="none";
document.all("imgFrame").style.display="none";
document.all("imgPic1").style.display="none";
document.all("imgPic2").style.display="none";
document.all("imgPic3").style.display="none";
document.all("imgPic4").style.display="none";
document.all("imgPic5").style.display="none";
}
alert("图片载入成功!");
}
function z()
{
document.all("ctl_loaded_zone").value=document.Form1.ctl_loaded_ddlZone.selectedIndex;
}
</script>

5、在提交时:

cmd.Parameters.Add("@province_id",SqlDbType.TinyInt).Value=((System.Web.UI.HtmlControls.HtmlInputHidden)this.FindControl("province")).Value;
cmd.Parameters.Add("@city_id",SqlDbType.TinyInt).Value=((System.Web.UI.HtmlControls.HtmlInputHidden)this.FindControl("city")).Value;
cmd.Parameters.Add("@zone_id",SqlDbType.TinyInt).Value=((System.Web.UI.HtmlControls.HtmlInputHidden)this.FindControl("zone")).Value;

【相关文章】好搜一下
实现Windows服务器高效管理的三大技巧

实现Windows服务器高效管理的三大技巧

技巧一:取消对服务器的限制访问为了提高员工的工作效率,单位最近打算把Window…