SPUG: cgi method popup_menu
Daniel V. Ebert
debert at osd.com
Tue May 16 10:51:12 CDT 2000
I usually create a hash of values and display labels for each pop-up menu I
want on a form. This should give you two seperate, unrelated pop-up menus.
I usually create the hash outside of the 'displayForm' subroutine so I can
use the labels in output generated by other subroutines. This might not be
the best way to do it, but it works :)
#!/usr/bin/perl -w
use CGI qw/:standard/;
$medalLabels{bronze} = "Bronze";
$medalLabels{silver} = "Silver";
$medalLabels{gold} = "Gold";
@medalKeys = keys %medalLabels;
$ribbonLabels{white} = "White";
$ribbonLabels{red} = "Red";
$ribbonLabels{blue} = "Blue";
@ribbonKeys = keys %ribbonLabels;
if (param()) {
processForm();
} else {
displayForm();
}
sub displayForm {
print
header,
start_html(-title =>'Test CGI',
-bgcolor =>'#FFFFFF'),
start_form;
print popup_menu(-name=>'medal',
-values=> \@medalKeys,
-labels=> \%medalLabels), p;
print popup_menu(-name=>'ribbon',
-values=> \@ribbonKeys,
-labels=> \%ribbonLabels), p;
print submit(-name=>' Process Form ')," ",
defaults(-name=>' Reset Form ');
print end_form, end_html;
} #END displayForm SUB
sub processForm {
#DO WHATEVER YOU WANT WITH THE FORM ENTRIES
} #END processForm
You wrote:
> If I make a call to the cgi method popup_menu more than
> once in a particular namespace it remembers the previous
> labels that were sent to it, then prints the previous popup_menu
> labels plus the new ones.
>
> I fixed the 'problem' by calling popup_menu inside a subroutine
> then passing the resulting text back to the calling routine.
> Apparently exiting the subroutine destroys the method.
>
> Is there a way to reuse the popup_menu without putting it
> in a subroutine?
>
> Joe
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
> For Subscriptions, Email to majordomo at pm.org: ACTION spug-list EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address
>
>
---
Dan Ebert
Seanet Internet Services
(206)343-7828
==============
"Comparing information and knowledge
is like asking whether the fatness
of a pig is more or less green than
the designated hitter rule."
-- David Guaspari
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
For Subscriptions, Email to majordomo at pm.org: ACTION spug-list EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address
More information about the spug-list
mailing list