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;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.