in reply to Perl-CGI refresh with different param(s)??
Hi,
When you fill out a form, and click submit, the form sends name/value pairs for each form input element to the url specified in the form's action attribute.
If the form specifies method="get", then the name/value pairs are tacked onto the end of the url specified in the form's action attribute. For instance:
http://www.some_site.com/dir1/page1.htm?name1=val1&name2=val2
The name value pairs are in this part:
name1=val1&name2=val2
Note that the name value pairs are separated by '&', and the whole series of name/value pairs is tacked onto the end of the url with a '?'.
If you want to provide links (= a tags) for your users with different name value pairs, then you can construct the url's with the desired name value pairs yourself. For instance:
use strict; use warnings; use 5.010; my $age = 10; my $name = 'Tom'; my $webpage = "http://www.somesite.com/page1.htm"; my $url = "$webpage?age=$age&name=$name";
The CGI.pm module allows you to use print() to send the html to the browser that you want the browser to display. So to display a link with the above url, you would do this:
Note that CGI.pm has some shortcut functions to print the doctype( header() ); the html, head, and opening body tag( start_html() ); etc.my $html =<<"END_OF_HTML"; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Title of the document</title> </head> <body> <div>Here is a link for you to search for blah blah blah:</div> <a href=$url>link1</a> </body> </html> END_OF_HTML print $html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl-CGI refresh with different param(s)??
by jonc (Beadle) on Jun 20, 2011 at 21:03 UTC | |
by 7stud (Deacon) on Jun 20, 2011 at 21:20 UTC | |
by jonc (Beadle) on Jun 20, 2011 at 21:29 UTC | |
by 7stud (Deacon) on Jun 20, 2011 at 21:47 UTC | |
by jonc (Beadle) on Jun 21, 2011 at 18:59 UTC |