Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: two submit buttons in a form

by sutch (Curate)
on Mar 12, 2001 at 07:59 UTC ( [id://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 }

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found