Hi,

I have a checkbox on click of which I'm calling a JavaScript function to disable another checkbox. The onClick event is not working in both Firefox/IE. I am capturing onChange event of the checkbox1 as of now which works in Firefox, but not working in IE.
Please suggest a way to implement this. This is urgent.

Thanx.

*Not working* is not a very helpful description of the problem. You should try debugging your script and inspecting variables to see if they are causing a problem. Use the Microsoft Script Debugger if using IE and Firebug if using Firefox.

Also, onclick works:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>Title</title>
    <META http-equiv="Content-Type" content="text/html; charset=utf8">
    <script type="text/javascript">
      function doDisable(elem, id) {
        var e = document.getElementById(id);
        if(!e || !elem)  return;
        e.disabled = elem.checked;
      }
    </script>
  </head>
  <body id="bdy">
    <form name="frm" id="frm" action="#">
      <div id="container">
        <input type="checkbox" id="chk1" name="chk1">
        <br><br>
        <input type="checkbox" id="chk2" name="chk2" onclick="doDisable(this, 'chk1');">
      </div>
    </form>
  </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.