How to obtain the select drop-down box value:
1. When the option in the drop-down box does not have the value Attribute
Copy codeThe Code is as follows:
<Select id = "param1">
<Option> Student ID </option>
<Option> name </option>
<Option> age </option>
</Seclect>
<Script>
Window. onload = funciton (){
Var param = document. getElementById ("param1 ");
Param. onchange = getParam (){
Var text = param. value;
}
}
</Script>
2. When the option in the drop-down box has the value attribute
Copy codeThe Code is as follows:
<Select id = "param1">
<Option> Student ID </option>
<Option> name </option>
<Option> age </option>
</Seclect>
<Script>
Window. onload = funciton (){
Var param = document. getElementById ("param1 ");
Param. onchange = getParam (){
Var selectIndex = param. selectIndex; // obtain the cited number of the selected option
Var text = param. options [selectIndex]. text;
</Script>