jquery - How to put the onchange event of a select list? -


i ready next problem. have select list populated follows:

<select id= "tables" name= "tables">     <option value="select">-- select --</option>     <option value = student> student</option>     <option value = teachers > teachers </option>     //etc.. </select> 

on onchange event of select list select list populated.

my first problem when select item, "student", view still remains on "select" option.i want should show item select.

my second query is, if not write "-- select --" , "student first item" when click student first time nothing happens means 2nd selct list doesnot populated.

please help!

assuming html :

<select id= "tables" name= "tables">     <option value="">-- select --</option><!-- setting value none -->     <option value = student> student</option>      <option value = teachers > teachers </option> </select> 

with jquery, it'll change event :

$('#tables').on('change', function(e) {     var value = $(this).val();      if(value.length != 0) {         alert(value);     }  }); 

see live example there.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -