Would something more like this do what you are looking for? I do not usually like to mix using CGI to write out the tags, and writing them myself... But this should at least be on the right track.

Instead of having 100 differently named checkboxes, why not just use 1 checkbox name for each day? All the boxes that are checked will be read by CGI as an array of the values of the boxes that were checked.

#! /usr/bin/perl use strict; use CGI; my @days = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); my @hours = ( "7am-8am", "8am-9am", "9am-10am", "10am-11am" ); my $q=CGI->new(); print $q->header, $q->start_html; print $q->start_form; print '<table><tr>', $q->td(); for my $hour (@hours) { print $q->td($hour); } print '</tr>'; for my $day (@days) { print '<tr>'; print '<td>', $day, '</td>'; for my $hour (@hours) { print $q->td($q->checkbox(-name=>$day, -value=>$hour, -label=>'' ) ); } print '</tr>'; } print '</table>'; print $q->submit; print $q->end_form; # Display the values to make sure it's doing the right thing print '<br>Values:<br><br>'; for my $day (@days) { print $day, '<br>'; print join('<br>', $q->param($day)); print '<br><br>'; } print $q->end_html;

In reply to Re: Converting large numbers of checkboxes to small number of params by oknow
in thread Converting large numbers of checkboxes to small number of params by MrCromeDome

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.