sam wrote:
> sam wrote:
>
>> Hi,
>>
>> I need to use CGI to construct a listbox.
>> I m currently using OO style of CGI.
>> Does anyone got an example how to use CGI to build a listbox?
>> I need to submit the values in the listbox to another CGI form, that's
>> why I need the listbox to be constructed by CGI.
>>
> Hi,
>
> I have written the following CGI code, but the listbox does not insert
> data to the listbox. These data is retrieved from the MySQL datasbase:
>
> my $values = "";
> my $lables = "";
> while ($aref = $sth->fetchrow_arrayref){
> $values .= $aref->[0].",";
> $labels .= $aref->[0]." => " .
> $aref->[1].":".$aref->[2].",";
> }
>
> print $query->scrolling_list(
> -NAME => "Examples",
> -VALUES => [ qw($values) ],
> -LABELS => {$labels},
>
> -SIZE => 3,
> -MULTIPLE => 1, # 1 for true, 0 for false
> );
>
> When I execute this code, the listbox is inserted with the string
> "$values" in the box instead of the values in the $values variable.
>
> What s wrong with this code?
>
Hi,
I have changed the above code to the following, it nearly working as I
expected:
my @values;
my @lables;
my $i;
for ($i=0; $aref = $sth->fetchrow_arrayref; $i++){
$values[$i] = $aref->[0]; #custcode
$labels[$i] = $aref->[1]; #custname
}
print $query->scrolling_list(
-NAME => "Outlets",
-VALUES => [@values],
-LABELS => \%labels,
-SIZE => 9,
-MULTIPLE => 1,
);
However it inserted custcode to the listbox. I m expecting custnames on
the "label=" side of the listbox, and custcode is on the "value=" side
of the listbox.
How can I fix this error?
> Thanks
> Sam
|