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.