Jeremy Kister wrote:
>
> Using an older (unknown version) and brand new (3.25) CGI, I have been
> able to demonstrate a simple bug:
>
> use strict;
> use CGI qw(:standard);
>
> my $q = new CGI();
>
> my $x = $q->param('x');
> my $y = ($x + 1);
>
> print $q->header(), $q->start_html(),
>       $q->hidden('x',$y), "\n",
>       $q->hidden('a',$y), "\n",
>       $q->end_html();
>
>
> using script.pl?x=5, you'll see that the cgi prints x=5 but a=6
>
> apparently only happens when you're setting a parameter via 'hidden'
> that was read by 'param'

No. It's the designed behaviour. The CGI documentation says this:

    Note, that just like all the other form elements, the value of a hidden
    field is "sticky". If you want to replace a hidden field with some other
    values after the script has been called once you'll have to do it
    manually:

         param('hidden_name','new','values','here');

The idea is that if a script both receives and displays form input then it is
probably redisplaying the same form, and it would be a shame to throw away the
input that the operator had already typed in.

It's also nothing to do with hidden values and param method calls. Try this:

use strict;
use CGI qw(:standard);

my $q = new CGI( {x => 5} );

print $q->header(),
      $q->start_html(),
      $q->textfield('x',6), "\n",
      $q->textfield('a',6), "\n",
      $q->end_html();

and you'll see it has the same result.

Oh, and I wonder if you were asking for help, which is what this list is for, or
just trumpeting that thought you'd discovered an error in someone else's work?

Anyway, I hope this helps.

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to