First, you may want to enclose your code in
<CODE></CODE>tags.
The following script demonstrates how to use CGI.pm to create checkbox groups and retrieve checked values:
#!/usr/bin/perl -w use CGI qw/ :standard /; use strict; my @checkbox_items = qw/one two three four five/; print header, start_html( -title => 'Checkbox group sample using CGI.pm' ), start_form; # The following code creates the checkbox group using the elements in # @checkbox_items print checkbox_group( -name => 'testing', -values => \@checkbox_items, -linebreak => 1, ), submit, end_form; # Here we retrieve and output the user-selected values of the checkbox + group. my @checkbox_values = param( 'testing' ); print p( 'Check a button or two and click Submit Query to see the chec +ked values.' ), li( \@checkbox_values ), end_html; print end_html;
Update: Many thanks to George_Sherston++ for pointing out that I was importing the CGI functions twice. I've modified the code to use only :standard.
Update: Thanks to CharlesClarkson++ for noting that li accepts a list ref. Code modified.
In reply to Re: Checkbox values
by Jazz
in thread Checkbox values
by chriso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |