Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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:

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;

Note that CGI.pm has some shortcut functions to print the doctype( header() ); the html, head, and opening body tag( start_html() ); etc.


In reply to Re: Perl-CGI refresh with different param(s)?? by 7stud
in thread Perl-CGI refresh with different param(s)?? by jonc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-16 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found