JavaScript Gets the Select Value method analysis _javascript techniques

Source: Internet
Author: User

The examples in this article describe the way JavaScript gets select values. Share to everyone for your reference. The specific analysis is as follows:

1. Get the displayed Kanji

Copy Code code as follows:
document.getElementById ("Bigclass"). Options[window.document.getelementbyid ("Bigclass"). SelectedIndex].text

2. Get the IDs in the database

Copy Code code as follows:
Window.document.getElementById ("Bigclass"). Value

3. Get the index ID of the select Group assignment

Copy Code code as follows:
Window.document.getElementById ("Bigclass"). SelectedIndex

Example:

<select name= "Bigclass" id= "Bigclass" onchange= "Javascript:updatepage2" (); " >
<option value= "" selected= "selected" >ajax experiment </option>
<option value= "4" > I fit the city ha </ Option>
</select>

Use:

Copy Code code as follows:
document.getElementById ("Bigclass"). Options[window.document.getelementbyid ("Bigclass"). SelectedIndex].text

The result: I am suitable for the city ha

Use:

Copy Code code as follows:
Window.document.getElementById ("Bigclass"). Value

The result: 4

Use:

Copy Code code as follows:
Window.document.getElementById ("Bigclass"). SelectedIndex

The result: 1

I hope this article will help you with your JavaScript programming.

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.