ibanja
asked on
perl CGI - How can I use an array in popup_menu?
In the following code I want to use an array to place the values instead of hard coding them in. Is this possible and what is the syntax?
start_form,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','b lue','char treuse']),
end_form;
Thanks,
Frank
start_form,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','b
end_form;
Thanks,
Frank
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
teraplane,
Being new to perl I may be missing something obvious but I couldn't get the solution to work so I went with ozo's. Thanks for the input though.
Being new to perl I may be missing something obvious but I couldn't get the solution to work so I went with ozo's. Thanks for the input though.
my @array = ('red','green','blue','cha rtreuse);
# just pass a reference to your array
print popup_menu(-name=>'color',
-values=> \@array),
end_form;
#or create a new reference containing your array
print popup_menu(-name=>'color',
-values=> [@array]),
end_form;
# just pass a reference to your array
print popup_menu(-name=>'color',
-values=> \@array),
end_form;
#or create a new reference containing your array
print popup_menu(-name=>'color',
-values=> [@array]),
end_form;
ASKER
Thanks ozo,
I have also discovered a missing single quote after chartreuse.
my @array = ('red','green','blue','cha rtreuse');
I have also discovered a missing single quote after chartreuse.
my @array = ('red','green','blue','cha
# just pass a reference to your array
popup_menu(-name=>'color',
-values=> \@array
end_form;