Built From Developers For Developers
» Kuikie.com » Snippets » JavaScript » Other » JavaScript. How to Find, if a Chekbox is Checked or Not
  Categories
  JavaScript
    Ajax
    IFrame
    Integers
    Other
    Strings
 

JavaScript. How to Find, if a Chekbox is Checked or Not

This little JavaScript snippet shows how to find, if a checkbox is checked or not.

<input type="checkbox" onclick="if(this.checked==true) { on_checked(); } else { on_not_checked(); }">

Example

This example shows a download button, if the user accepts the terms and conditions.

<input type="checkbox" onclick="if(this.checked==true) { document.getElementById('button_download').style.display = 'block'; } else { document.getElementById('button_download').style.display = 'none'; }"> Do you agree with the Terms and Conditions?
<button id="button_download" style="display:none;">Download

Test

Do you agree with the Terms and Conditions?
 
©2012 Sinevia Ltd Terms of Use         Privacy Policy Valid XHTML 1.0 Transitional