Jeff Prachyl Jeff Prachyl - 3 months ago 10
Javascript Question

Call javascript function only when checkbox is NOT checked

I'm trying to figure out how to call a javascript function only when a checkbox is NOT checked.

here is my checkbox:

<input type="checkbox" id="icd" name="icd" value="icd" />


here is the name of the function:

planhide();


Thanks!

Answer
document.getElementById('icd').onchange = function() {
    if ( document.getElementById('icd').checked === false ) {
        planhide();
    }
};‚Äč