//添加List:传入两个参数(目标List,来源List)
function insertList(tarObj,srcObj){
if (srcObj.selectedIndex==-1){
return
}
//产生一个option组件
var opt = document.createElement("option");
//把opt加到目标List里
tarObj.options.add(opt);
//指定opt的value及text
opt.innerText = srcObj.options[srcObj.selectedIndex].innerText;
opt.value = srcObj.options[srcObj.selectedIndex].value;
//加入到目标List后,移除来源List中的选项
srcObj.remove(srcObj.selectedIndex);
document.form1.Form_Num.value = tarObj.options.length
document.form1.Form_Numshow.value = tarObj.options.length
}
//删除List:传入两个参数(目标List,来源List)
function deleteList(tarObj,srcObj){
if (srcObj.selectedIndex==-1){
return
}
//产生一个option组件
var opt = document.createElement("option");
//把opt加到目标List里
tarObj.options.add(opt);
//指定opt的value及text
opt.innerText = srcObj.options[srcObj.selectedIndex].innerText;
opt.value = srcObj.options[srcObj.selectedIndex].value;
//加入到目标List后,移除来源List中的选项
srcObj.remove(srcObj.selectedIndex);
}
然后引用的引用这两个function即可