1. check whether item2. of value = "paravalue" exists in the select option. Add item3. Delete item4. from the select option, modify the text of value = "paravalue" in the select option to "paravalue" paratext "5. set the first item of text = "paratext" in select to select 6. set item of value = "paravalue" in select to select 7. obtain the value8of the selected item in the SELECT statement. Obtain the text9of the selected item in the SELECT statement. Get the index10of the selected item in the SELECT statement. Clear the select item ----------------------------- // 1. determine whether itemfunction jsselectisexititem (objselect, objitemvalue) {var isexit = false; For (VAR I = 0; I <objselect. options. length; I ++) {If (objselect. options [I]. value = objitemvalue) {isexit = true; break;} return isexit;} // 2. add an itemfunction jsadditemtoselect (objselect, objitemtext, objitemvalue) to the select option {// determine whether there is if (jsselectisexititem (objselect, objitemvalue )) {alert ("the value of this item already exists");} else {var varitem = New Option (objitemtext, objitemvalue); // objselect. options [objselect. options. length] = varitem; objselect. options. add (varitem); alert ("successfully added") ;}// 3. delete An itemfunction jsremoveitemfromselect (objselect, objitemvalue) from the select option {// determine whether there is if (jsselectisexititem (objselect, objitemvalue )){
For (VAR I = 0; I <objselect. options. length; I ++) {If (objselect. options [I]. value = objitemvalue) {objselect. options. remove (I); break ;}} alert ("deleted successfully") ;}else {alert ("this select does not exist") ;}} // 4. modify the text of value = "paravalue" in the select option to "paratext" function jsupdateitemtoselect (objselect, objitemtext, objitemvalue) {// determine if (jsselectisexititem (objselect, objitemvalue )) {for (VAR I = 0; I <objselect. options. length; I ++) {If (objselect. options [I]. value = objitemvalue) {objselect. options [I]. TEXT = objitemtext; break; }} alert ("modified successfully ");}Else {alert ("this select does not exist") ;}// 5. set the first item of text = "paratext" in select to the selected function jsselectitembyvalue (objselect, objitemtext) {// determine whether var isexit = false; For (VAR I = 0; I <objselect. options. length; I ++) {If (objselect. options [I]. TEXT = objitemtext) {objselect. options [I]. selected = true; isexit = true; break;} // show the result if (isexit) {alert ("selected successfully ");} else {alert ("this select does not exist") ;}// 6. set the item of value = "paravalue" in select to select // document. all. objselect. value = objitemvalue; // 7. obtain the value/var currselectvalue = Document of the selected item in the SELECT statement. all. objselect. value; // 8. the text // var currselecttext = document. all. objselect. options [document. all. objselect. selectedindex]. text; // 9. the index // var currselectindex = document. all. objselect. selectedindex; // 10. clear select items // document. all. objselect. options. length = 0;