Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to handle multiple buttons inside CGI form

by graff (Chancellor)
on Feb 03, 2015 at 05:41 UTC ( [id://1115339]=note: print w/replies, xml ) Need Help??


in reply to How to handle multiple buttons inside CGI form

If I understand you correctly, you either want to use radio buttons (if you want to allow only one choice from your presets to be selected) or checkboxes (if you want to allow any number of presets to be selected).

You can refer to the parts of the CGI man page that describe "CREATING A RADIO BUTTON GROUP" or "CREATING A GROUP OF RELATED CHECKBOXES" (to be found under "CREATING FILL-OUT FORMS").

In either case, all "preset" buttons are associated with a single parameter, and the value of that parameter will depend on which radio button (or which checkbox(es)) the user clicks before hitting the "submit" button.

  • Comment on Re: How to handle multiple buttons inside CGI form

Replies are listed 'Best First'.
Re^2: How to handle multiple buttons inside CGI form
by doubledecker (Scribe) on Feb 03, 2015 at 05:53 UTC

    Thank you for your valuable suggestion. I implemented Radio Button group but one of the value is getting selected by default. Unless user select any choice, how can i deselect radio buttons without turning them on??

      Maybe provide an "opt out" button and make that the default so that that is an explicit option. After all, after the user has made a choice they can't go back to the original page state unless you provide an additional button.

      Perl is the programming world's equivalent of English
      Maybe this... http://perldoc.perl.org/CGI.html#PRAGMAS
      -nosticky By default the CGI module implements a state-preserving behavior called "sticky" fields. The way this works is that if you are regenerating a form, the methods that generate the form field values will interrogate param() to see if similarly-named parameters are present in the query string. If they find a like-named parameter, they will use it to set their default values. Sometimes this isn't what you want. The -nosticky pragma prevents this behavior. You can also selectively change the sticky behavior in each element that you generate.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found