• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • Last Modified:

perl, cgi to read whether a check box value if it is checked

<INPUT TYPE="checkbox" NAME="snif0" checked="yes" >emA
<INPUT TYPE="checkbox" NAME="snif1" checked="no" >emB
<INPUT TYPE="checkbox" NAME="snif2" checked="no" >emC
<INPUT TYPE="checkbox" NAME="snif3" checked="yes" >emD

If the boxes are checked then add to array @sniffList.  So @snifList should have emA and emD?
0
rgbcof
Asked:
rgbcof
  • 2
  • 2
1 Solution
 
EZFragCommented:
Hi there,
Here is some snippets of how I do it.

Hope it helps ^_^
HTML
----------

<input type="checkbox" name="snif" value="emA"> emA<br>
<input type="checkbox" name="snif" value="emB"> emB<br>
<input type="checkbox" name="snif" value="emC"> emC<br>
<input type="checkbox" name="snif" value="emD"> emD<br>

-------
PERL
-------

my @snif= param('snif');
foreach my $snif(@snif) {
   print "You picked $snif.<br>\n";
}

Open in new window

0
 
rgbcofAuthor Commented:
Got an error:

Undefined subroutine &main::param called at  /var/www/cgi-bin/p ....
0
 
EZFragCommented:
Oh, sorry 'bout that, here is the full source for the perl script.
#!/usr/bin/perl

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

print header;
print start_html;

my @snif= param('snif');
foreach my $snif(@snif) {
   print "You picked $snif.<br>\n";
}


print end_html;

Open in new window

0
 
rgbcofAuthor Commented:
Very cool.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now