in reply to Re^2: Reload a script with a new value for input when submit is clicked on an html form
in thread Reload a script with a new value for input when submit is clicked on an html form

<input type="text"/> <input type="submit" value="submit"/>
should be
<input type="text" name="text"> <input type="submit" value="submit">

You didn't name the input field, so it wasn't getting sent to the server. Also, that slash is illegal HTML (although some browsers ignore it).

Both GET and POST will work, but I'd recommend GET here since the request has no side-effects.

  • Comment on Re^3: Reload a script with a new value for input when submit is clicked on an html form
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: Reload a script with a new value for input when submit is clicked on an html form
by Lady_Aleena (Priest) on Feb 23, 2010 at 19:00 UTC

    Thank you so very much! *gives cookies*

    Working code

    #!/usr/bin/perl use strict; use warnings; use CGI; use HTML::Entities qw(encode_entities); print "content-type: text/html \n\n"; my @options = qw(text color background_color); my @family = qw(serif sans-serif cursive fantasy monospace); my @size = qw(xx-small x-small small medium large x-large xx-large); my @weight = qw(normal bold 100 200 300 400 500 600 700 800 900); my @variant = qw(normal small-caps); my @style = qw(normal italic oblique); my $cgi = CGI->new(); my $text = encode_entities($cgi->param('text')) || "The quick brown fo +x jumps over the lazy dog."; my $color = encode_entities($cgi->param('color')) || "#000"; my $background_color = encode_entities($cgi->param('background_color') +) || "transparent"; print <<"sec1"; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/T +R/html4/strict.dtd"> <html><head><title>Font and Color Tests</title> <style type="text/css"> h1 {font-size:14pt;} h2 {font-size:12pt;} p {border:1px #333 solid;} </style> </head> <body> <h1>Font and Color Tests</h1> <form action="$ENV{REQUEST_URI}" method="get"> sec1 for my $option (@options) { my $display_option = ucfirst $option; $display_option =~ tr/_/ /; print qq{<div>\n<label for="$option">$display_option: </label>\n<inp +ut type="text" id="$option" name="$option">\n</div>}; } print <<"sec2"; <div> <input type="submit" value="submit"> <a href="font.pl">Start over</a> </div> </form> sec2 for my $style (@style) { for my $variant (@variant) { for my $weight (@weight) { for my $size (@size) { for my $family (@family) { print qq{<h2>style: $style; variant: $variant; weight: $weig +ht; size: $size; family: $family; color: $color; background-color: $b +ackground_color;</h2>\n}; print qq{<p style="font:$style $variant $weight $size $famil +y;color:$color;background-color:$background_color;">$text</p>\n}; } } } } } print "</body></html>";
    Have a nice day!
    Lady Aleena