Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Cannot clear cgi param (if it's really what I need to do)

by kyle (Abbot)
on Jan 30, 2008 at 17:10 UTC ( #665165=note: print w/replies, xml ) Need Help??


in reply to Cannot clear cgi param (if it's really what I need to do)

According to the CGI documentation (under "CREATING FILL-OUT FORMS"), you have to tell it that you really mean for the parameter to be what you asked it to be. (I have found this behavior annoying frequently, but it is documented.)

use CGI; my $cgi = CGI->new(); $cgi->param( 'mode', 'orig' ); print $cgi->hidden( 'mode', 'second arg' ), "\n"; print $cgi->hidden( -name => 'mode', -default => 'default', ), "\n"; print $cgi->hidden( -name => 'mode', -default => 'forced', -override => 1 ), "\n"; __END__ <input type="hidden" name="mode" value="orig" /> <input type="hidden" name="mode" value="orig" /> <input type="hidden" name="mode" value="forced" />

Replies are listed 'Best First'.
Re^2: Cannot clear cgi param (if it's really what I need to do)
by lepetitalbert (Monsignor) on Jan 30, 2008 at 18:34 UTC

    Hi kyle,

    I came accross the '-override', but as I

    print hidden(); instead of print $cgi->hidden()

    it has no effect.

    Thank you.

    Have a nice day

    "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

      This does not appear to be the case.

      BEGIN { $ENV{QUERY_STRING} = 'mode=orig'; $ENV{REQUEST_METHOD} = 'GET'; } use CGI qw( hidden ); print hidden( 'mode', 'second arg' ), "\n"; print hidden( -name => 'mode', -default => 'default', ), "\n"; print hidden( -name => 'mode', -default => 'forced', -override => 1 ), "\n"; __END__ <input type="hidden" name="mode" value="orig" /> <input type="hidden" name="mode" value="orig" /> <input type="hidden" name="mode" value="forced" />

      Perhaps your code is doing something different from what you think it's doing?

        Hi kyle,

        As I print other hidden params

        print hidden( 'day' , $day );

        I printed this one

        print hidden( 'mode' , 'save' , 1 );

        and this don't work.

        print hidden( -name => 'mode' , -default => 'save' , -override => 1);

        works, but I don't understand why ?

        Have a nice day.

        "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://665165]
help
Chatterbox?
[Discipulus]: good morning monks and nuns!
[Corion]: Hi Discipulus, Happy-the-monk!
[Corion]: There is demand for an emergency Frankfurt.pm social meeting, as two people from Strasbourg.pm are in Frankfurt on Wednesday - I'll forward the mail in the evening
[Discipulus]: beer finished in Strasbourg? ;=)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2018-07-23 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (459 votes). Check out past polls.

    Notices?