selectadd.js

来自「本代码是为客户联系管理而做的系统」· JavaScript 代码 · 共 38 行

JS
38
字号
function addElement(inputname, selectname) {	// get the field objects	var input = document.getElementById(eval('inputname')); 	var select = document.getElementById(eval('selectname')); 	// add element	select.options[select.options.length] = new Option(input.value, input.value);	input.value = '';}function removeFrom(inputname, selectname) {	// get the field objects	var input = document.getElementById(eval('inputname')); 	var select = document.getElementById(eval('selectname')); 	if (select.selectedIndex == -1) {		alert("Please select an item to remove");		return false;	}		for (i=select.options.length - 1;i>=0; i--) { 	   if (select.options[i].selected) { 		   select.options[i] = null; 	   }    } }function selectSubmit(selectname) {	// select all the fields	var select = document.getElementById(eval('selectname')); 	for (i=select.options.length - 1;i>=0; i--) { 	   select.options[i].selected = true;   } }

⌨️ 快捷键说明

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