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

📄 selectutil.js

📁 彩信DIY 彩信DIY
💻 JS
字号:
//动态处理select控件的方法

function Category(OperationType,cid,title)
{
        if(OperationType!=""&&cid!=""&&title!="")
        {
		        this.OperationType = OperationType;
                this.cid = cid;
                this.title = title;
        }
}

function AddOption (sText,sValue,obSelect2) 
{
	var pObj = document.getElementById(obSelect2);
	for(var i=0;i<pObj.options.length;i++){
		if(pObj.options[i].value==sValue){
			return;
		}
	}
	var newItem = document.createElement("OPTION") ;
	newItem.text =  sText ;
	newItem.value =  sValue ;
	pObj.add(newItem);		
}

//删除所有的option
function DelOption (obSelect2) 
{
	var iLength = document.getElementById(obSelect2).options.length ;
	for ( var i = iLength - 1 ; i >= 0 ; i -- )
		document.getElementById(obSelect2).options[i]=null ;
}

function Init(sArray, obSelect1, obSelect2)
{
	ChangeChild(document.getElementById(obSelect1).value, sArray, obSelect2);
}

//删除选中的option
function deleteSelectedOption(obSelect2){
    var test =  document.getElementById(obSelect2);
	if(test.selectedIndex!=-1){
    test.options[test.selectedIndex]=null ;
    }
	else{
	    alert("请选择要删除的项!");
	}
}

//获取指定下拉列表框的值数组
function getOptionValueArray(obSelect2){
    var sel = document.getElementById(obSelect2);
	var objOptions = new Array(sel.options.length);
	
	for ( var i = 0 ; i < sel.options.length ; i++ )
		objOptions[i] = sel.options[i].value;
	return objOptions;
}

//获取指定下拉列表框的文本数组
function getOptionTextArray(obSelect2){
    var sel = document.getElementById(obSelect2);
	var objOptions = new Array(sel.options.length);
	
	for ( var i = 0 ; i < sel.options.length ; i++ )
		objOptions[i] = sel.options[i].text;
	return objOptions;
}

⌨️ 快捷键说明

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