Whenever I click a checkbox, I encounter the error "Unable to get the value of the property 'checked'. object is null or undefined."
The form I am working with has the name 'test', and my objective is to display additional input fields depending on whether the first check box is checked. If it passes by it without being selected, then I do not want the other fields to be displayed.
Take a look at the script below:
function toggleFields()
{
if (document.test.submode.checked) {
document.getElementById("hideablearea").style.display = "block";
} else {
document.getElementById("hideablearea").style.display = "none";
}
}
This is the line involving my input:
<input type="checkbox" name="submode" onclick="toggleFields()">
I'm curious if there's a way to enhance my JavaScript code to ensure its compatibility across different web pages and browsers. Any suggestions?