⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 provcity.js

📁 OA.....其他人不需帐号就可自由下载此源码其他人不需帐号就可自由下载此源码
💻 JS
字号:


function Roly_ProvCity() {
	this.obj = this;
	this.province = "";
	this.city = "";
	this.list = [];
}
function Roly_ProvCity_Province() {
	this.name = "";
	this.cityList = [];
}

Roly.ProvCity.prototype.parseXml = function() {
	var xml = document.all.ProvinceCity;
	if(xml == null || xml == undefined) {
		alert("Error:Can't find xml data!");
		return;
	}
	var root = xml.documentElement;
	
	var def = root.firstChild;
	this.province = def.getAttribute("province");
	this.city = def.getAttribute("city");
	
	for(var i=1;i<root.childNodes.length;i++) {
		var pNode = root.childNodes[i];
		var bean = new Roly.ProvCity.Province();
		bean.name = pNode.getAttribute("name");

		for(var j=0;j<pNode.childNodes.length;j++) {
			var cNode = pNode.childNodes[j];
			bean.cityList[bean.cityList.length] = cNode.getAttribute("name");
		}

		this.list[this.list.length] = bean;
	}
}

Roly.ProvCity.prototype.init = function(p,c) {
	this.parseXml();
	if(p=="null" || c=="null") {
		p = "";
		c = "";
	}
	this.province = p;
	this.city = c;
	var slt_usr = $("province");
	var slt_dpt = $("city");
	if(slt_usr == null || slt_dpt == null)
		return;
	slt_usr.length = 0;
	slt_usr.param = this;
	slt_usr.onchange = this.changeProxy;

	var blank = document.createElement("option");
	blank.setAttribute("value","");
	blank.appendChild(document.createTextNode("------"));
	slt_usr.appendChild(blank);

	slt_dpt.length = 0;
	for(var i=0;i<this.list.length;i++) {
		var bean = this.list[i];
		var op = document.createElement("option");
		op.setAttribute("value",bean.name);
		op.appendChild(document.createTextNode(bean.name));
		if(this.province == bean.name)
			op.selected = true;
		slt_usr.appendChild(op);
	}

	if(this.province != "") {
		this.change(this.province,this.city);
	} else {
		this.change(slt_usr.options[0].value,this.city);
	}

}

Roly.ProvCity.prototype.changeProxy = function() {
	var S = $("province");
	var obj = S.param;
	var prov_name = S.options[S.selectedIndex].value;
	obj.change(prov_name);
}

//褰撻

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -