JS select the relevant drop-down box method
function createSelect(){
var mySelect = document.createElement(select);
mySelect.id = mySelect;
document.body.appendChild(mySelect);
} 2. Add Options option
function addOption(){
According to ID lookup object,
var obj=document.getElementById('mySelect');
Add an option
obj.add(new Option( Text , Value ));
} 3. Delete all option option
function removeAll(){
var obj=document.getElementById('mySelect');
obj.options.length=0;
} 4. Option to delete an option
function removeOne(){
var obj=document.getElementById('mySelect');
index, The number you want to delete option, remove the currently selected option here the ordinal number
var index=obj.selectedIndex;
obj.options.remove(index);
} 5. To obtain the option value option
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; Ordinal number, take the ordinal number of the currently selected option
var val = obj.options[index].value; 6. To obtain a copy option option
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; Ordinal number, take the ordinal number of the currently selected option
var val = obj.options[index].text; 7. Edit Options option
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; Ordinal number, take the ordinal number of the currently selected option
var val = obj.options[index]=new Option( The new text , The new value ); 8. Delete select
function removeSelect(){
var mySelect = document.getElementById(mySelect);
mySelect.parentNode.removeChild(mySelect);
}
Related Posts of JS select the relevant drop-down box method
-
Test js select select
Test js select select
-
AJAX cascading drop-down menu related drop-down lists
Q & A at xu_ch see ask a question about the drop-down list. Think of, made a before about using AJAX, dynamic update cascade similar pull-down menu function. To take this opportunity to organize them a bit useless. It is said that a classic origi ...
-
JavaScript and jsp secondary structure linked the drop-down box without refresh
Meeting (2005-10-25) finishing This article does not use Ajax technology, the use of a single deposit of JavaScript + Jsp + DHTML to achieve Paragraph keyword database table ID SuperID relations Select page to double Read data , achieve dynamic linke ...
-
js Simplified Traditional conversion code
js Traditional Traditional Traditional Traditional javascript code conversion conversion code Reprint Address: http://www.cnblogs.com/genson/archive/2008/04/16/1004632.html js Simplified, Traditional conversion, IE7 through, Firefox does not pass, th ...
-
js to obtain the drop-down list to select the value and text (select), as well as access to radio buttons (radio) group and modify the selected value of
First, access the drop-down list to select the value and text (select) Second, access to radio buttons (radio) group and modify the selected value of To see a lot of posts said js access the radio button (radio) group can be directly used the value o ...
-
js version of Ant Colony Algorithm
js version of Ant Colony Algorithm
-
Rails use of select
Assumptions have the following drop-down list box In the rails in the implementation of such a list box, you can use the following method 1) The use of select 2) Use select_tag 3) Use collection_select
-
rails provinces cascade implementation
Page code is as follows: Provinces in the list box: City list box: js: action in the code are as follows:













Leave a Reply