Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: two submit buttons in a form

by sutch (Curate)
on Mar 12, 2001 at 07:59 UTC ( #63733=note: print w/ replies, xml ) Need Help??


in reply to two submit buttons in a form

Test the value of the parameter named "bloption". For example, if your CGI object is $q, try:

if ($q->param("bloption") eq "add") { # add buddy code here } elsif ($q->param("bloption") eq "delete") { # delete buddy code here }


Comment on Re: two submit buttons in a form
Download Code
Re: Re: two submit buttons in a form
by Masem (Monsignor) on Mar 12, 2001 at 08:53 UTC
    I'm not sure if this is expected behavior, or a cavaet, or something else... when I do this (two submits on the same page) using the same NAME parameter, I get back from CGI with that name parameter an array, which only has one elements, that being the VALUE of the submit button that was hit. It's easy enough to check to see if what CGI returns is an array or not, but it seems odd and undocumented. The only thing that might be affecting this is that I use short phrases for the VALUEs, so the multiplicity of words might be causing this, but seems doubtful.
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
      The only way that I can duplicate this behavior is to request the value(s) of the parameter in list context:

      my @value = $q->param("bloption");

      Otherwise, CGI.pm returns a scalar with the value of bloption. Examining the URL of the submitted form (that contains the two submit buttons), I can see that only one value for bloption is actually being submitted:

      http://localhost/~sutch/test/index.cgi?bloption=add

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2014-09-01 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls