JS dynamic add option and delete option

Source: Internet
Author: User

1. Dynamic creation of SELECT

function Createselect () {     var myselect = document.createelement ("select");     Myselect.id = "Myselect";     

2. Add Options option

function AddOption () {     //Find object by ID,     var obj=document.getelementbyid (' Myselect ');     Add an option     obj.add (new option ("Text", "value"));//This only works in IE     

3. Remove all options option

function RemoveAll () {     var Obj=document.getelementbyid (' Myselect ');     

4. Delete an option

function Removeone () {     var Obj=document.getelementbyid (' Myselect ');     Index, to delete the ordinal of the option, take the current selected option of the Ordinal     var index=obj.selectedindex;     

5. Get the value of option options

6. Get the text of options option

7. Modify Options option

8. Delete Select

function Removeselect () {     var myselect = document.getElementById ("Myselect");     

  

JS dynamic add option and delete option

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.