note
golux
Hi deathmetalscottie,
<p>Make sure that you have a name defined for the <select> tag. In your code,you're using "$key", which you never define:
<c>
my $key;
...
<select name="$key" size="15" multiple="multiple">
</c>
So if you fix that, for example, calling it "multi":
<c>
my $name = "multi"; # Renamed from $key to be less confusing
# Sorry, I don't want to show my /etc/password :)
my %user = (
'fred' => 101,
'barney' => 102,
'wilma' => 103,
'betty' => 104,
'pebbles' => 105,
'bambam' => 106,
);
...
<select name="$name" size="15" multiple="multiple">
foreach my $key(sort keys %user) {
my $val = $user{$key};
if ($val > 100) {
print qq{<option value="$key">$key ($val)</option><br />};
}
}
</c>
Then you can see with a quick test which names were chosen, in sum.cgi, like this:
<c>
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser/;
use Data::Dumper;
my @users = param('multi');
die sprintf "Users selected: %s\n", Dumper(\@users);
</c>
For example, selecting the 2 values "bambam (106)" and "pebbles (105)":
<c>
*** bambam (106) ****
barney (102)
betty (104)
fred (101)
*** pebbles (105) ***
wilma (103)
</c>
and clicking "Go!" to call sum.cgi should show:
<c>
Software error:
Users selected: $VAR1 = [
'betty',
'wilma'
];
</c>
<div class="pmsig"><div class="pmsig-941867">
<center><font size="-1">
<font color="#ff0000">say </font>
<font color="#ffbf3f">substr</font><font color="#c8871a">+</font><font color="#9f4f06">lc </font><font color="#711f79">crypt</font><font color="black">(<font color="#a9df2d">qw </font><font color="#4df9ff">$i3 </font><font color="#4db2ff">SI$</font>),4,5</font></font></center>
</div></div>
1005875
1005875