select - javascript onclick alert not working in chrome -


<select name="history" id="history" >  <option value="history 1" onclick="alert('h1');">history 1</option>  <option value="history 2" onclick="alert('h2');">history 2</option>  <option value="clearhistory" onclick="this.form.submit();" >clear history</option> </select> 

could me script? expecting whenever user clicks history 1 ..it alert h1 script works in firefox , ie not in chrome :(

use onchange instead of onclick select lists.

<select name="history" id="history" onchange="historychanged(this);">  <option value="history1">history 1</option>  <option value="history2">history 2</option>  <option value="clearhistory">clear history</option> </select>  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript">  function historychanged() {     var historyselectlist = $('select#history');     var selectedvalue = $('option:selected', historyselectlist).val();      alert(selectedvalue);      if (selectedvalue == 'clearhistory') {         historyselectlist.form.submit();     } }  $(function() {     alert('my alert');     $('select#history').change(historychanged); });  </script> 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -