Select the dropdown box, and when you select an option, the foreground displays a change, and you know which options are selected.
This is a good solution:
As follows:
<div class= "Page-header" >
<div class= "Form-horizontal" >
<div class= "Control-label col-lg-0" >
</div>
<div class= "col-lg-2" >
<select class= "Form-control" onchange= " Selectonchang (This) ">
<option> men </option>
<option> Women's </option>
< Option> Children's Wear </option>
<option have passed the audited merchant </option>
</select>
</div>
</div>
Js:
function Selectonchang (obj) {
//Get the selected option label option
alert (obj.selectedindex);
}
The onchange and SelectedIndex are used here.
The onchange event occurs when the contents of the domain change.
The onchange event can also be used for events that are triggered when a radio box and a check box change.
SelectedIndex: Sets or returns the index number of the selected item in the Drop-down list.
This will trigger a change when we change the option.
In doing so, we can only get the selected item, and if we select which item, we need to pass special information, what should we do at this time?
<div class= "Page-header" >
<div class= "Form-horizontal" >
<div class= "Control-label col-lg-0" >
</div>
<div class= "col-lg-2" >
<select class= "Form-control" onchange= " Selectonchang (This) ">
<option value=" Men "> Menswear </option>
<option value=" wemen "> Ladies </ option>
<option value= "Childe" > Children's Wear </option>
<option value= "Yunfu" > Maternity dress </option>
</select>
</div>
</div>
In other words, I want to get that value when I select it, and how to do it at this time.
There is only one way to do this, and there should be plenty of other ways.
function Selectonchang (obj) {
var value = Obj.options[obj.selectedindex].value;
alert (value);
}
The above is a small set for you to introduce the Select dropdown box and value of the solution, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!