in reply to Converting large numbers of checkboxes to small number of params
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;
|
---|
Replies are listed 'Best First'. | |
---|---|
(jeffa) 2Re: Converting large numbers of checkboxes to small number of params
by jeffa (Bishop) on Jul 09, 2003 at 23:45 UTC | |
Re: Re: Converting large numbers of checkboxes to small number of params
by Anonymous Monk on Jul 13, 2003 at 07:37 UTC |
In Section
Seekers of Perl Wisdom