Add, modify, and delete option elements in Firefox and Opera,select compatible with the following code:
function Watch_ini () {//Initial
for (var i=0; i<arguments.length; i++) {
var ooption=new option (Arguments[i],arguments[i]);
document.getElementById ("Myselect"). Options[i]=ooption;
}
}
function Watch_add (f) {//Increase
var ooption=new option (F.word.value,f.word.value);
F.keywords.options[f.keywords.length]=ooption;
}
Frequently used about select option Operations
Create an Option Object
function createoption () {
var random = Math.floor (Math.random () *9000) +1000;
return new option (RANDOM,RANDOM);
}
Deletes an option specified in the Options collection
function Removeoption (index) {
if (index >= 0) {
Colls.remove (index);
Lastoptiononfocus (colls.length-1);
}
Watchstate ();
}
Gets the currently selected option index
function Getselectedindex () {
return selecttag.selectedindex;
}
Get the total number of options collections
function Getoptionlength () {
return colls.length;
}
Gets the currently selected option text
function Getcurrentoptionvalue (index) {
if (index >= 0)
Return Colls (index). value;
}
Gets the currently selected option value
function Getcurrentoptiontext (index) {
if (index >= 0)
Return Colls (index). text;
}
Use the last item in the options collection to get focus
function Lastoptiononfocus (index) {
Selecttag.selectedindex = index;
}