Hi Monks
I am creating a popup_menu each time I am fetching a new set of values from the database. But I am running into a problem as default values of popup_menus are retained across queries.
I am using a conditional statement as below, please help me with a way so that every time it is created the previous values are not maintained.
I think I am making some syntax error and have to mention it as an array ref but not sure how can I do that while using
a conditional statement
while(defined (my $row = $stmt->fetchrow_hashref)) { my $x = $row->{CONNECTION}; my $y = $row->{CARRY}; my $drop_down = $cgi->popup_menu( -name => "CHOICE", -values => [ 0 .. 6 ], -labels => { 0 => 'NO', 1 => 'A', 2 => 'B', 3=> 'C', 4 => 'D', 5 => 'E', 6 => 'F' }, -default => ($row->{CONNECTION} eq 'Y' && $row->{CARRY}) ? $row->{CARRY}: 0, );
When the above mechanism did not work, I tried the following one as well i.e taking the decision first in an if-else and then assigning the value but it did not work either :
while(defined (my $row = $stmt->fetchrow_hashref)) { my $x = $row->{CONNECTION}; my $y = $row->{CARRY}; my $default; if ($x eq 'Y') { if ($y) { $default = $y; } } my $drop_down = $cgi->popup_menu( -name => "CHOICE", -values => [ 0 .. 6 ], -labels => { 0 => 'NO', 1 => 'A', 2 => 'B', 3 => 'C', 4 => 'D', 5 => 'E', 6 => 'F' }, -default => $default, );
In reply to popup_menus retaining values across queries by simonz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |