[Ie&firefox compatible] JS to select operation _ form Effects
Source: Internet
Author: User
Today in the Ajax use of two Drop-down boxes dynamically add options in the Select, when I am in the normal use of IE test in Firefox is not normal use, I am not very familiar with the script, so the Internet check to find them in the dynamic add option when a little different.
Take him down below, and you might use it later:
To delete all options in a select dynamically:
function Deletealloptions (SEL) {
sel.options.length=0;
}
To delete an option in a select dynamically:
function Deleteoption (sel,indx) {
Sel.options.remove (INDX);
}
Dynamically add items in Select option:
function AddOption (sel,text,value) {
Sel.options.add (New Option (Text,value));
}
Above in IE and Firefox can test success, I hope you can use it later.
In fact, with the standard DOM operation is also possible, that is, document.createelement,appendchild,removechild and so on. :)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.