Hide elements with checkbox

By | May 7, 2012

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



<script type="text/javascript">	
	function DisplayElement(checked) 
		if (checked) {
			document.getElementById('text').style.display = '';
		else {
			document.getElementById('text').style.display = 'none';
<form name="form">
<input type="checkbox" onclick="DisplayElement(this.checked)" checked/>
<input type="text" id="text"/>

Leave a Reply

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