Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 }

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 - || "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, 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:


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2020-07-06 12:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found