After returning from home today after taking annual leave, I saw the "Monitoring and Management Demonstration Code" posted by Xiao Lin on QQ. The core principle is the add() method of the select element:
function watch_ini(){ // Initial
for(var i=0; i
var word = document.createElement("OPTION");
word.text = arguments[i];
watch.keywords.add(word); // watch. is form name
}
}
function watch_add(f){ // Add
var word = document.createElement("OPTION");
word.text = f.word.value;
f. keywords.add(word);
}
But the above add() method is only valid under IE. In order to be compatible with FF and Opera, the above code has been improved. The modified code is as follows :
function watch_ini(){ // Initial
for(var i=0; i
var oOption=new Option(arguments[i],arguments[i]);
document.getElementById("MySelect").options[ i]=oOption;
}
}
function watch_add(f){ // Add
var oOption=new Option(f.word.value,f.word.value);
f.keywords.options[f.keywords.length]=oOption;
}