The easiest way is to use CGI.pm. It will repopulate all your
fields automatically when the page is redrawn after a submit.
Try this code: #!/usr/bin/perl
use CGI qw(:standard);
$cgi = new CGI;
print header(), start_html();
print start_form(-action=>$cgi->script_name());
print hidden(-name=>'PrevSelect', -value=>$cgi->param('Select'));
%labels = ("foo"=>"Foo", "bar"=>"Bar", "baz"=>"Baz");
print popup_menu(-name=>'Select',
-values=>[keys %labels],
-default=>'baz',
-labels=> \%labels);
print submit();
print end_form(), end_html();
It will preserve whatever is in the popup_menu (<SELECT>) selection after an action has been taken. |