Solved

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

Posted on 2010-11-11
4
536 Views
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?
0
Comment
Question by:rgbcof
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:EZFrag
Comment Utility
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
 

Author Comment

by:rgbcof
Comment Utility
Got an error:

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

Accepted Solution

by:
EZFrag earned 250 total points
Comment Utility
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
 

Author Closing Comment

by:rgbcof
Comment Utility
Very cool.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now