Click to See Complete Forum and Search --> : how to deselect radio button


munna
11-20-2003, 04:50 PM
Hi,
Can anyone please tell me how I can get radio buttons to behave like checkboxes -- selected on first click and deselected on clicking again? I remember seeing a small javascript snippet somewhere that did this, but can't remember where!
Please put me out of my misery by telling me how to do this,
Munna

96turnerri
11-20-2003, 05:08 PM
the easiest way would be to have a reset form button you could do it like this tho

Button
<script type="text/javascript">
function check(button) {
if (button.checked)
button.checked=false

}
</script>

<form>
<input name="radio1" type="radio" value="">
<input type="button" value="" onClick=check(radio1)>
</form>

Text
<script>
function check(button) {
if (button.checked)
button.checked=false

}
</script>

<form>
<input name="radio1" type="radio" value="">
<a href="#" onClick="check(radio1)">Deselect</a>
</form>

or when user moves mouse out of form

<script>
function check(button) {
if (button.checked)
button.checked=false

}
</script>

<form onMouseOut="check(radio1)">
<input name="radio1" type="radio" value="">
</form>

can be other ways but theres a few