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

Posted on 2010-11-11
Last Modified: 2013-12-25
<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?
Question by:rgbcof
  • 2
  • 2

Expert Comment

ID: 34118137
Hi there,
Here is some snippets of how I do it.

Hope it helps ^_^

<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>


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

Open in new window


Author Comment

ID: 34118330
Got an error:

Undefined subroutine &main::param called at  /var/www/cgi-bin/p ....

Accepted Solution

EZFrag earned 250 total points
ID: 34118343
Oh, sorry 'bout that, here is the full source for the perl script.

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


Author Closing Comment

ID: 34118349
Very cool.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question