Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-11
4
Medium Priority
?
595 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:EZFrag
ID: 34118137
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
ID: 34118330
Got an error:

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

Accepted Solution

by:
EZFrag earned 1000 total points
ID: 34118343
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
ID: 34118349
Very cool.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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 …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

609 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