How to detect checkbox state in Javascript IE7

Posted by justinl on Stack Overflow See other posts from Stack Overflow or by justinl
Published on 2010-05-05T04:18:40Z Indexed on 2010/05/05 4:28 UTC
Read the original article Hit count: 405

Filed under:
|
|

I have a simple checkbox on my website. Everytime you check and uncheck it, it shows an alert as to what the state is. This works flawlessly in FF, Chrome, and IE8. However, when I run this in IE7, no matter if the check is on or off, it always alerts "off". It's like IE7 can't detect that the checkbox is checked.

Does anyone have an idea of how to fix this or work around it? I basically need to toggle the visibility of some content based on a checkbox, but IE7 is being difficult. Thanks!

Here is my code that I'm using:

function showHideTimeDropdown()  
{   
  if (document.getElementById("input_checkbox").checked == true){
    alert("on");
  }
  else{  
    alert("off");  
  }  
}

© Stack Overflow or respective owner

Related posts about ie7

Related posts about JavaScript