in reply to Displaying values after form is submitted

Consider using a table:
#!/usr/local/bin/perl -w #use strict, warnings, web cgi, and browser error modules use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $fetch_data = ''; my ($field, $value); foreach $field (param) { #added this loop to cover multivalued form fields to #process each value individually if needed foreach $value (param($field)) { $fetch_data .= "<tr><td>$field:</td><td>$value</td></tr>\n"; } } print header, <<"EOF"; <HTML> <BODY> <table> $fetch_data </table> </HTML> EOF

Replies are listed 'Best First'.
Re: Re: Displaying values after form is submitted
by Anonymous Monk on May 12, 2004 at 14:35 UTC
    Thanks to all it works great. The only area I now need newlines for a specific field is where the user enters information in a textarea box on my form:
    Enter the city or cities

    and the person could enter several cities in the textbox area where they type in the city and hit the enter key and then type in another city such as this in the textbox:
    San Francisco
    San Diego


    Currently that entry will show up as this on my web page results:
    City: San Francisco San Diego

    Anyway to have just the textarea entries show up like this with a newline after each city entered?
    City: San Francisco
    San Diego

    Here is my attempt:
    foreach $value (param($field)) { if($field !~ /city/) { $fetch_data .= "<tr><td>$field:</td><td>$value</td></tr>\n"; } elsif($field =~ /city/) { $textareaField .= "City\:\t$value\n\n<br\>"; } } } print header, <<"EOF"; <HTML> <BODY> <table> $fetch_data $textareaField </table> ---- <TEXTAREA name="city" ROWS="4"></TEXTAREA>