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

📄 select.js

📁 1、用SQL查询器打开install目录下的dooogo.sql运行之后创建数据库dooogo。 2、然后打开web.config修改 <DbProvider type="Club.Fram
💻 JS
字号:
// JavaScript Document
/********************************************************************
主题:下拉框操作类(Dec.2005)
作者:Issac
主页:http://www.douneed.com
邮箱:issacdd@gmail.com
********************************************************************/
// JavaScript Document
/********************************************************************
主题:下拉框操作类(Dec.2005)
作者:Issac
主页:http://www.douneed.com
邮箱:issacdd@gmail.com
********************************************************************/

function BindSelect (xmlFile) {
	this.xmlFile = xmlFile;
	if (window.ActiveXObject)
		this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	else if (document.implementation&&document.implementation.createDocument)
		this.xmlDoc=document.implementation.createDocument("","doc",null);
	else {
		alert("很抱歉,您的浏览器暂不支持该脚本,建议使用IE6!");
		return;
	}
	this.xmlDoc.async = false;
	this.xmlDoc.preserveWhiteSpace = true;
	this.xmlDoc.load(this.xmlFile);
	this.rootNode = this.xmlDoc.documentElement;
	
	//增加菜单数据
	this.addData = function (obj, value, text) {
		var op = document.createElement("option");
		op.value = value;
		op.innerHTML = text;
		obj.appendChild(op);
	};
	//删减菜单数据
	this.delData = function (obj, num, value) {
		if (num != null && value == null) {
			if (num <= obj.options.length)
				obj.options[num-1] = null;
			return;
		}
		else if (num == null && value != null) {
			for (var i=0; i<obj.options.length; i++)
				if (obj.options[i].innerHTML.replace(/\s/gi,"") == value.replace(/\s/gi,"")) {
					obj.options[i] = null;
					return;
				}
		}
		else {
			obj.options[obj.options.length-1] = null;
			return;
		}
	};
	//清空菜单数据
	this.clearData = function (obj) {
		for (var i=obj.options.length -1; i>=0; i--)
			obj.options[i] = null;
	};
	
	//绑定菜单数据
	this.BindData = function (obj, selItem, elem) {
		var _elem = elem || this.rootNode;
		obj.style.width = "";	//和下文的"obj.style.width = 'auto';"共同作用菜单使其适应内容
		for (var i=0; i<_elem.childNodes.length; i++) {
			with (_elem.childNodes[i]) {
				if (nodeType!=1) continue;
				var op = document.createElement("option");
				if (attributes[0])
					op.value = attributes[0].value;
				op.innerHTML = firstChild.nodeValue;
				if (selItem!=null) {
					if (selItem.split(",").length==1 && selItem.replace(/\s/gi,"")==op.value)
						op.selected = true;
					else if (selItem.split(",").length==2 && selItem.split(",")[1].replace(/\s/gi,"")==op.innerHTML.replace(/\s/gi,""))
						op.selected = true;
				}
			}
			obj.appendChild(op);
		}
		obj.style.width = "auto";
	};
	
	//联动菜单全局变量
	this.gearObjArray = new Array();
	this.gearTotal = new Array();
	this.elemArray = new Array();
	//绑定联动菜单
	this.BindGear = function (objArray, selItem, newName) {
		this.gearGroup = (typeof(this.gearObjArray[this.gearGroup])=="undefined") ? 0 : (this.gearGroup+1);	//定义联动组
		this.gearObjArray[this.gearGroup] = objArray;
		this.gearTotal[this.gearGroup] = objArray.length;
		this.elemArray[this.gearGroup] = new Array();
		this.elemArray[this.gearGroup][0] = this.rootNode;
		if (selItem == null) {
			this.BindData (this.gearObjArray[this.gearGroup][0]);
			this.viewGearIndex(0);
		}
		else {
			this.selArray = new Array();
			for (var i=0; i<selItem.split("|").length; i++)
				this.selArray[i] = selItem.split("|")[i];
			this.BindData (this.gearObjArray[this.gearGroup][0], this.selArray[0]);
			for (var i=0; i<this.gearTotal[this.gearGroup]-1; i++)
				eval ("this.doGear("+i+", this.selArray["+i+"], "+this.gearGroup+")");
		}
		if (newName != null)
			for (var i=0; i<this.gearTotal[this.gearGroup]-1; i++)
				eval ("this.gearObjArray[this.gearGroup]["+i+"].onchange = function() {"+newName+".doGear("+i+", null, "+this.gearGroup+")}");
	};
	//执行联动操作
	this.doGear = function (prt, selItem, group) {
		this.gearGroup = group;
		for (var i=prt+1; i<this.gearTotal[this.gearGroup]; i++)
			this.gearObjArray[this.gearGroup][i].style.display = "block";
		var _elem = this.elemArray[this.gearGroup][prt];
		this.clearData (this.gearObjArray[this.gearGroup][prt+1]);
		for (var i=0; i<_elem.childNodes.length; i++) {
			if (_elem.childNodes[i].nodeType!=1) continue;
			if (selItem != null) {
				if (selItem.split(",").length==1) {
					var _selItem = selItem;
					if (_elem.childNodes[i].attributes[0] && _elem.childNodes[i].attributes[0].value.replace(/\s/gi,"") == _selItem.replace(/\s/gi,"")) {
						this.BindData (this.gearObjArray[this.gearGroup][prt+1], this.selArray[prt+1], _elem.childNodes[i]);
						this.elemArray[this.gearGroup][prt+1] = _elem.childNodes[i];
						return;
					}
				}
				else if (selItem.split(",").length==2) {
					var _selItem = selItem.split(",")[1];
					if (_elem.childNodes[i].firstChild.nodeValue.replace(/\s/gi,"") == _selItem.replace(/\s/gi,"")) {
						this.BindData (this.gearObjArray[this.gearGroup][prt+1], this.selArray[prt+1], _elem.childNodes[i]);
						this.elemArray[this.gearGroup][prt+1] = _elem.childNodes[i];
						return;
					}
				}
			}
			else if (_elem.childNodes[i].firstChild.nodeValue.replace(/\s/gi,"") == this.gearObjArray[this.gearGroup][prt].options[this.gearObjArray[this.gearGroup][prt].options.selectedIndex].innerHTML.replace(/\s/gi,"")) {
				if (_elem.childNodes[i].childNodes.length>1) {
					this.BindData (this.gearObjArray[this.gearGroup][prt+1], null, _elem.childNodes[i]);
					this.elemArray[this.gearGroup][prt+1] = _elem.childNodes[i];
					this.viewGearIndex (prt+1);
					return;
				}
				else
					this.hideNullGear (prt+1);
			}
		}
	};
	//显示其余联动首项
	this.viewGearIndex = function (prt) {
		var _elem = this.elemArray[this.gearGroup][prt];
		for (var i=0; i<_elem.childNodes.length; i++) {
			if (_elem.childNodes[i].nodeType!=1) continue;
			if (_elem.childNodes[i].firstChild.nodeValue.replace(/\s/gi,"") == this.gearObjArray[this.gearGroup][prt].options[this.gearObjArray[this.gearGroup][prt].options.selectedIndex].innerHTML.replace(/\s/gi,"")) {
				if (_elem.childNodes[i].childNodes.length>1)
					this.addGearIndex(prt+1,_elem.childNodes[i]);
				else 
					this.hideNullGear (prt+1);
			}
		}
	};
	//增加联动菜单首项
	this.addGearIndex = function (curr, elem) {
		for (var i=0; i<elem.childNodes.length; i++) {
			if (elem.childNodes[i].nodeType!=1) continue;
			this.clearData (this.gearObjArray[this.gearGroup][curr]);
			this.addData (this.gearObjArray[this.gearGroup][curr],elem.attributes[0],elem.childNodes[i].firstChild.nodeValue);
			if (elem.childNodes[i].childNodes.length>1)
				this.addGearIndex(curr+1, elem.childNodes[i]);
			else 
				this.hideNullGear (curr+1);
		}
	};
	//隐藏空联动
	this.hideNullGear = function (num) {
		for (var i=num; i<this.gearTotal[this.gearGroup]; i++) {
			this.clearData(this.gearObjArray[this.gearGroup][i]);
			this.gearObjArray[this.gearGroup][i].style.display = "none";
		}
	};
}

⌨️ 快捷键说明

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