Hide elements with checkbox


This is a slightly edited version of this post. Just to make it work with a checkbox instead of radio buttons.

 

 
[html]
<html>
<head>
<script type="text/javascript">
function DisplayElement(checked)
{
if (checked) {
document.getElementById(‘text’).style.display = ”;
}
else {
document.getElementById(‘text’).style.display = ‘none’;
}
}
</script>
</head>
<body>
<form name="form">
<input type="checkbox" onclick="DisplayElement(this.checked)" checked/>
<input type="text" id="text"/>
</form>
</body>
</html>
[/html]

Leave a Reply

Your email address will not be published. Required fields are marked *