Re: Dilemma with Radio Buttons
by Alan Carvalho <alancarv(at)sti.com.br>
|
Date: |
Mon, 20 Nov 2000 04:48:42 -0200 |
To: |
hwg-basics(at)mail.hwg.org |
In-Reply-To: |
home |
|
todo: View
Thread,
Original
|
|
[Kate]
>It seems that the only way to deselect it is to select another. But we
>don't want that. We want to CLEAR ONLY this field (since it might be a
>mistake) without clearing the entire form. Is there any way to either:
>a) program that in OR
>b) instruct the user how to deselect it.
[Alan]
Yes, it's possible. Here is an example using a button to deselect all the
radio buttons in a group.
<html>
<head>
<title>Clearing a radio button</title>
<script language="javascript">
function Zero(banana) {
for (i=0; i<banana.f_color.length; i++)
banana.f_color[i].checked = false;
}
</script>
<body>
<form name="test">
What's your favorite color?
<input type="radio" name="f_color" value="1">Blue
<input type="radio" name="f_color" value="2">Red
<input type="radio" name="f_color" value="3">Green
<input type="radio" name="f_color" value="4">Yellow
<input type="button" value="Deselect"
onclick="Zero(this.form);">
</form>
</body>
</html>
Note: I used < and > instead the HTML brackets to avoid problems with
e-mail readers that understand HTML.
I hope help you.
Sorry the poor english.
Alan Carvalho
Sao Paulo, Brazil
HTML: hwg-basics mailing list archives,
maintained by Webmasters @ IWA