Get the value in Select all option

Source: Internet
Author: User

get the value in Select all option.

2012-02-24 11:04:43| Category: HTML| Report | Font size Subscription

1://get all the option number
document.getElementById ('---'). options.length

2://Gets the ID value for each option
document.getElementById ('---'). Options[i].value

3://gets the text that each option displays on the page
document.getElementById ('---'). Options[i].text

4://Determines whether the option is selected
document.getElementById ('---'). options[i].selected = = True

5://set this option to selected
document.getElementById ('---'). options[i].selected = True

6://, remove all option
document.getElementById (dayselecttagname). options.length=0;

7. Regenerate option
To generate a new option object
The first false means that it is not selected by default
The second false indicates that only a single selection
var newoption=new Option (Newoptionvalue,newoptionvalue,false,false);
Add the newly generated option to the Select tab
document.getElementById (dayselecttagname). Options[i-1]=newoption;

Get the value in Select all 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.