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> All applications for business </option> <option> to be
audited merchant </option>
<option> failed to approve merchant </option>
<option> approved 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.
Effect as shown:
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= ' All ' > All applications for Business </option>
<option value=" check_pending "> to be audited merchant </option>
<option value=" No "> failed to approve merchant </option>
<option value=" yes "> Approved merchant </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 effect chart is as follows:
The above is a small set to introduce the bootstrap about select Drop-down box to select trigger events and expansion, 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!