I have a task to show or hide a form based on the status of a checkbox in a Google web application. If the checkbox is checked, then the form should be visible; otherwise, it should be hidden. I attempted to achieve this using the code provided below, but it didn't work as expected:
if (document.getElementById("df1").checked) {
document.getElementById("co").style.visibility = "hidden";
} else {
document.getElementById("co").style.visibility = "visible";
}
<form id="co" style="visibility: hidden">
<br>
<label type="text">Name </label><input type="text">
<br>
<label type="text">Roll No. </label><input type="number" value="0" min="0">
<br><br>
<input type="submit" value="submit">
<input type="checkbox" id="df1">