Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Clear radio buttons in form

by belize (Deacon)
on Aug 10, 2001 at 02:14 UTC ( [id://103680]=perlquestion: print w/replies, xml ) Need Help??

belize has asked for the wisdom of the Perl Monks concerning the following question:

This is not strictly a perl question, but it does involve a form generated by a CGI written in Perl.

I have a CGI that is printing out a form. Part of the is a series of radio buttons. When the CGI first prints out the form, all buttons are unselected. If while filling out the form, I select one of hte buttons, then decide that I do not want to select a button, I can't find a way to unselect the button.

With a checkbox, you only have to unselect the box. Is there some coding other than a dummy radio button that I can put to unselect a selected radio button?

Thanks.

Replies are listed 'Best First'.
Re: Clear radio buttons in form
by mischief (Hermit) on Aug 10, 2001 at 12:44 UTC

    In addition to the other answers, you can always do what Perlmonks does - put another radio button in the form as a kind of "null" choice. eg, if you have a form which says "choose which type of topping you want on your pizza", with a radio button for users to chooose between ham and sausage, put a "don't care" option in.

Re: Clear radio buttons in form
by George_Sherston (Vicar) on Aug 10, 2001 at 04:14 UTC
    Is it possible you don't actually need a radio button here? They're generally used for choosing between two or more options, rather than a yes / no to a single option (for which checkboxes are designed). But if you do want to use a radio button here, I think the answer is javascript. This should see you right:
    <form name="mainform"> <input type=radio name="foo" onclick="bar()"> <script language="javascript"> var i=0; function bar() { i=Math.abs(i-1); document.mainform.foo.checked=i; } </script> </form>


    § George Sherston
Re: Clear radio buttons in form
by c (Hermit) on Aug 10, 2001 at 07:17 UTC
    Completely not perl related, but you could put in an html tag of <input type=reset value="RESET"> which i think will reset the buttons to all unchecked. The downside being that it will clear ALL the fields in your form that the end user has filled out.

    humbly -c

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://103680]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-29 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found