Dear Monks,
I'm writing a CGI form that I want to behave differently based on the value of a URL query string (e.g. http::/localhost/cgi-bin/test_form?url_group=Boston3). Once the form has been filled out, I want to provide a button to let the user start over, while still maintaining the original param from the URL. I have tried using $query->hidden('url_group') to pass the URL param along until the last part of the script in which I have essentially:
But this doesn't work. The script just gets called as if $url_group were undefined. Below I have a simple test case:my $url_group = $query->param('url_group'); print start_form(-action=>"test_form.pl?$url_group"); print $query->defaults; print end_form;
Even if I refresh the browser with the query string still in the URL, it doesn't get passed the param. (I have to browse the script first *without* the query string, and then browse again *with* the query string, at which point it the param gets used initially.) Interestingly, a *link* to the script using the query string does work...but I'd rather use a button in the real script. Any idea how I can get this to work?use strict; use warnings 'all'; use CGI qw(:standard); my $query = CGI->new(); my $url_group; if ($query->param('url_group') =~ m/^(Boston[1|2|3])$/) { $url_group = 'url_group=' . $query->param('url_group'); } print header, start_html; print "<p><b>\$query->param('url_group') = </b>\"" . $query->param('ur +l_group') . "\"</p>"; print p("<b>The value of \$url_group is:</b> $url_group"); print start_form(-action=>"test_form.pl?$url_group"); print $query->defaults("This doesn't pass the group"); print end_form; print end_html; print p("<b><a href=test_form.pl?$url_group>This does work</a></b>") i +f ($url_group);
In reply to Can't seem to pass query string with start_form(-action=>"test_form.pl?$url_group") by memnoch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |