RICHARD FERNANDEZ am Sunday, 24. September 2006 02:15: > > $query->param(-name=>'foo', -value=>'the value'); > > Make that line $query->param(-name=>'foo', -value=>"$the_value"); > > Then somwhere at the start where you get the variables; > > my $name = $query->param('name')||''; > > if ($name =~/mary/i){ $the_value = "Howdy Mary" } > > > > How you do it depends on your workflow/logic > > > > Owen
Hello Richard > Thanks for your response, but I still don't get it. I type my name into > the box and click > Submit, but it doesn't change! > > Could you please clarify? > > Here's my code: > > #!/usr/bin/perl -w > # This script is the example at the top of the CGI pod --richf; > use strict; > use CGI; > > my $html = new CGI; > > my $new_value; my $new_value=''; > my $name = $html -> param('name') or ''; This should read: my $name = $html->param('name') || ''; due to the precedence of the operators: '||' > '=' > 'or' See perldoc perlop ('' is never assigned to $new_value with 'or') And please don't use spaces around '->' :-) > if ($name =~ /richf/i) { > $new_value = 'John'; > } > > print $html -> header, > $html -> start_html('A Simple Example'), > $html -> h1('A Simple Example'), > $html -> start_form, > > "What's your name?", > $html -> textfield(-name => 'name'), Here's the source of your problem: the textfield value is missing: $html->textfield(-name => 'name', -value => $new_value), > $html -> p, > "What's the combination?", > $html -> p, > $html -> checkbox_group(-name=>'words', > -values=>['eenie','meenie','minie','moe'], btw, above line can be written shorter: -values=>[ qw( eenie meenie minie moe ) ], > -defaults=>['eenie','minie']), > $html -> p, > "What's your favorite color?", > $html -> popup_menu(-name=>'color', > -values=>['red','green','blue','chartreuse']), > $html -> p, > $html -> submit, > $html -> end_form, > $html -> hr; > > > > $html -> param(-name => 'name', -value => $new_value); This will only change the value in the request object, but not in the form! (also part of your problem) > print $html -> end_html; Hope this helps! Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>