I’m trying to use Javascript to detect whether a checkbox has been checked. My plan is to allow the user to select the checkbox in order to mark a letter as printed and then use Ajax to update the database.
Here is the code I’m using.
<label for="printed">Printed</label>
<input type="checkbox" name="8200" id="8200" value="P" onclick="checked(this.id);" />
<script type="text/javascript">
function checked(id) {
var remember = document.getElementById(id);
if (remember.checked){
alert("checked");
}else{
alert("You didn't check it!");
}
}
</script>
All I get in return is an error saying Uncaught TypeError: boolean is not a function from Google Chrome and checked is not a function from Firefox.
You should use a different name to your javascript method, as the boolean checked field of the input just hides the one you’ve defined…