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); } });
Comments
Post a Comment