var obj = document.getElementById("mySelect"); var index = obj.selectedIndex; obj.options[index] = new Option( "three",3); //Change the corresponding value obj.options[index].selected = true; //Keep the selected state
function addOption(){ //Find objects based on id, var obj=document.getElementByIdx_x('mySelect'); //Add an option obj.add(new Option("text","value")); //This is only valid in IE obj.options.add(new Option("text", "value")); //This is compatible with IE and firefox }
removefunctionOne(){ var obj=document.getElementByIdx_x('mySelect'); //index, to delete the serial number of the option, here take the serial number of the currently selected option var index=obj .selectedIndex; obj.options.remove(index); }
var obj=document.getElementByIdx_x('mySelect'); var index=obj.selectedIndex ; //Serial number, take the serial number of the currently selected option var val = obj.options[index].value;
var obj=document.getElementByIdx_x('mySelect'); var index=obj.selectedIndex; //Serial number, take the serial number of the currently selected option var val = obj.options[index].text;
var obj=document.getElementByIdx_x('mySelect '); var index=obj.selectedIndex; //Serial number, take the serial number of the currently selected option var val = obj.options[index]=new Option("new text", "new value");
function watch_ini(){ // 初始 for(var i=0; ivar word = document.createElement_x("OPTION"); word.text = arguments[i]; watch.keywords.add(word); // watch. is form name } } function watch_add(f){ // 增加 var word = document.createElement_x("OPTION"); word.text = f.word.value; f.keywords.add(word); }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn