Onclick event firing in Firefox and IE but not in Chrome

google-chrome, html, javascript, php

Solution

option elements don't fire the click event in all browsers, you should stray away from relying on this. Instead you can use onchange() event for select. You may use something like this

<html>
 <head>
  <script type="text/javascript">

   function changeFunc() {
    var selectBox = document.getElementById("selectBox");
    var selectedValue = selectBox.options[selectBox.selectedIndex].value;
    alert(selectedValue);
   }

  </script>
 </head>
 <body>
  <select id="selectBox" onchange="changeFunc();">
   <option value="1">Option #1</option>
   <option value="2">Option #2</option>`enter code here`
  </select>
 </body>`enter code here`
</html>

In Your case you use like

<form id='myForm' action="#">
  <select id='mySelect' name="moduleidval" class="validate['required']" onchange="showhidefields(this.value,this.form,'0');">
   <option value="-">-- Selecteer Proces--</option>
   <option value="1"> 'Klantprocessen'</option>
</select>
</form>

Problem

I have the following javascript function. ``` <script type="text/javascript"> function showhidefields(value,formobj,epsflag,respflag) { //alert(epsflag); if (epsflag==0 && respflag==4) { document.getElementById("tpnr").style.position = "static"; document.getElementById("tpnr").style.top = "0px"; formobj.tussenPersoonNotext.disabled =false; formobj.email.disabled =true; } </script> <select name="moduleidval" class="validate['required']"> <option value="">-- Selecteer Proces--</option> <option onclick="showhidefields(this.value,this.form,'<?php echo 1; ?>');" value="<?php echo $epsmodules; ?>"><?php echo 'MBO'; ?></option> </select> ``` My problem is when i click on the option in case of `firefox` or `IE` the onclick event fires but in case of chrome it doesnot fire at all.i tried changing the function name also but no luck. fiddle thanks in Advance

Original source