0

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.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by ~s.o.s~
0

*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>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.