Ok, that works!
But I never realized this before.
Quite contra intuitive.
And what about the /per/ dir...
So if you could still be so kind as to look at the code sample below:

On Sat, 12 Jan 2002, Ged Haywood wrote:

> Hi again,
> 
> On Sat, 12 Jan 2002, Arnold van Kampen wrote:
> 
> > (only the plain string works, not the function textfield() after
> > several submissions)
> 
> Try this instead of the first line in your handler:
> 
>   my $r=shift;
>   my %params = ($r->method eq 'POST') ? $r->content : $r->args;
>   my $bla = $params{'position'} + 10;
> 
> I think you'll find the second line there in the Guide somewhere.
> 
[ I tried this with ./httpd -X ]

So it is possible to create a textfield with another name and show it with
the new value. The textfield with the same name will remain unchanged! 
So textfield(-name=>position, -value=>$bla) will not accept submission
value from field with name position. 
But textfield(-name=>position2, -value=>$bla) will accept the value from
field position!
When using the string code the 'position' field will accept the new data
after submission.


I did not find these among the misteries before..
Very Strange. Is this a well known pittfall?


Arnold


#!/usr/bin/perl  
# file bla.cgi

use strict;
use CGI  qw(:standard :html3 :netscape );

CASE: {
        if (defined(param('forward'))) {
                $_ = param('forward');  
                /^first/i and do {second_show();last CASE;};
                /^second/i and do {first_show();last CASE;};

        }
        
        first_show();
}
exit 0;

sub first_show() {

        my @deel_display =();
        
        my $position = param('position');

        my $ref = ref($position);

        my $somename_data = param('somename');
        push @deel_display, td('param: '.param('position'));    
        my $bla = $position + 10;
        push @deel_display, td('param + 10: '.$bla);    
        push @deel_display, td('hidden value: '.$bla);  
        push @deel_display, td(textfield(-name=>'position', -value=>$bla));     
        push @deel_display, td(textfield(-name=>'position2', -value=>$bla));    
        push @deel_display, td(textfield(-name=>'position3', -value=>$ref));    
        push @deel_display, td(hidden(-name=>'somename', -value=>$bla));        
        
#       push @deel_display, "<td><input type=text name=position value=".$bla."></td>";
        
        my $button_value='first';
        push @deel_display, td(submit(-name=>'forward', -value=>$button_value));



        print header(-pragma=>'no-cache'),
        start_html(-title => 'visualise'), 
        start_multipart_form(-method=>'post'),
                table({-valign=>'top',border=>'1'},Tr(\@deel_display)),
        endform,
        end_html();

}


sub second_show {
        my @deel_display =();
        
        my $position = param('position');
        push @deel_display, td('param: '.param('position'));    
        my $bla = $position + 10;
        push @deel_display, td('param + 10: '.$bla);    
        push @deel_display, td(textfield(-name=>'position', -value=>$bla));     
#       push @deel_display, "<td><input type=text name=position value=".$bla."></td>";
        push @deel_display, td(submit(-name=>'forward', -value=>'second'));



        print header(-pragma=>'no-cache'),
        start_html(-title => 'visualise'), 
        start_multipart_form(-method=>'post'),
                table({-valign=>'top',border=>'1'},Tr(\@deel_display)),
        endform,
        end_html();


}
> 73,
> Ged.
> 

Reply via email to