Hello,

I was hoping to get a little advice creating a cgi form. I want to create a popup menu to list all the states in the US( and then later countries), I want to store all the values in variables to pass to the subroutines later on. The below code works, I just have the values for the states stored in a hash which is unorderd and diplayed as such on the form. I would like the popup menu display to keep the order from below. Also adding modules like Hash::Ordered and Tie::IxHash isn't an option. Is there a better way of doing this or am I just making it overly complicated? Thanks for any help you can give.

#!/usr/bin/perl
use warnings;
use strict;
use CGI qw(:standard escapeHTML);

use CGI::Carp qw(fatalsToBrowser);
BEGIN {open(STDERR,">error.log");}

my (@address, @state, $choice);

@address =
({name => "last_name", label => "Last name:", size => 20, req => 1},
{name => "first_name", label => "First name:", size => 20, req => 1},
{name => "business_name", label => "Business name:", size => 40},
{name => "address1", label => "Street address:", size => 40, req => 1},
{name => "addreess2", label => "", size => 40},
{name => "city", label => "City:", size => 20, req => 1}
);
@state =
({name => "state/prov", label => "State/Prov:", values => {"AK" => "Alaska", "AL" => "Alabama",
"AR" => "Arkansas", "AZ" => "Arizona" => "CA" => "California", "CO" => "Colorado",
"MT" => "Montana", "NC" => "North Carolina", "ND" => "North Dakota", "NE" => "Nebraska",
"NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NV" => "Nevada",
"NY" => "New York", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania",
"PR" => "Puerto Rico", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota",
"TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VA" => "Virginia", "VI" => "Virgin Islands",
"WA" => "Washington", "WI" => "Wisconsin", "WV" => "West Virginia", "WY" => "Wyoming",
"OTHER" => "OTHER (Outside USA)"}}
);
#************************
foreach $f (@{$address}) {
$label = $f->{label};
$label .= " *" if $f->{req}; # add asterick for required fields
push(@row, Tr(td(escapeHTML($label)),
td(textfield(-name => $f->{name}, -size => $f->{size}))
));
} print table(@row);


foreach $f (@{$state}) {
$label = $f->{label};
push (@row, Tr ( td (escapeHTML ($label)),
td (popup_menu (-name => $f->{name}, -value => $f->{values}))
));
}
print table(@row),
submit(-name => "choice", -value => "Submit"),















-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to