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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.