Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Quick Param Question

by rodion (Chaplain)
on Mar 29, 2007 at 02:13 UTC ( [id://607140]=note: print w/replies, xml ) Need Help??


in reply to Quick Param Question

Try
unless (param('submit'))
to detect if perl was invoked from a form. (If you've used submit(-name=>'somename'),then substitute "somename" for "submit".)

When you just check to see if param() returns false, you're checking that there were no parameters, but when you specify "id=2" in a link, you do have a parameter. Checking for a parameter named "submit" checks if the "submit" button was clicked (or the user pressed enter), which is what lests you know the other parameters were set by the form, not a link.

Replies are listed 'Best First'.
Re^2: Quick Param Question
by f00li5h (Chaplain) on Mar 29, 2007 at 03:17 UTC

    rodion, why not check all the form components automatically with a nice library, rather than checking for a single parameter to make it all work?

    Checking param( submit ) doesn't work well, particularly for complex, multi-stage forms, or forms with more than one operation, like:

    email:_______________
    [subscribe] [unsubscribe]

    or something wth a

    [<< back ][forward >> ]
    wizzard style interaction model.

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;
      It's worth pointing the questioner in a better direction, and it's also worthwhile explaining the problem he's run into where he is.

      Your advice is good, I agree with it, and the OP will do well to look further in the direction of CGI::FormBuilder, as you suggested in the first post.

      My take on the OP's question was that he was somewhat new to forms and parameters, was working from the example givin in the CGI module, and was a bit puzzled by the code from that example not working for him. My aim was to help him understand what was going on a little better, in answer to the "I cant figure this thing out." plea at the end of his post.

        rodion++

        Good point.

        @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-28 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found