javascript - How to fire onchange event of combobox? -


I have a combobox, how come the event of kickboxes comes on and gets a selected value from it.

Even the code that I have done so far:

  & lt; Select name = "g1" id = "select_g1" & gt; & Lt; Option value = "one" & gt; A & lt; / Options & gt; & Lt; Option value = "two" & gt; Two & lt; / Options & gt; & Lt; Option value = "three" & gt; Three & lt; / Options & gt; & Lt; / Select & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("select_g1"). Change (function () {warning ("handle"); // alert has not been removed ...});}); & Lt; / Script & gt;  Edit:  If I have more than one combo box:  
  & lt; Choose Name = "g2" & gt; & Lt; Option value = "one" & gt; A & lt; / Options & gt; & Lt; Option value = "two" & gt; Two & lt; / Options & gt; & Lt; Option value = "three" & gt; Three & lt; / Options & gt; & Lt; / Select & gt;   

/ Instead of using .change events, please try to use .on event. P>

You can try to use it this way:

  $ ('# select_g1'). ('Change', function (e) {var option> selected = $ ("option: selected", this); var value selected = this.value; warning (value selected);});  

See it here ->

Edit:

Regarding your edited question, ' the option '' '). ('Disabled', wrong); Select var option $ ("option: selected", this); Var value selected = this.value; Warning (value selected); Attit ("disabled", "disabled");});

Check it out here: $ ("option": select "" ("+ + value selected" ->

Demo for multiple combos

here ->

Hope it helps !!! < / P>


Comments