Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Clear radio buttons in form

by belize (Deacon)
on Aug 10, 2001 at 02:14 UTC ( #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?


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);; } </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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2021-03-01 17:09 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (15 votes). Check out past polls.