in reply to Converting large numbers of checkboxes to small number of params
Each day was passed to my Perl script as an array of checkboxes. Reading and parsing them as parameters was then as easy as:<tr align="center" bgcolor="#eeeeee"> <td bgcolor="#cccccc"><b>Monday</b> </td> <td width="6%"><input type="checkbox" name="Monday" value="7a8a" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="8a9a" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="9a10a" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="10a11a" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="11a12p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="12p1p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="1p2p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="2p3p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="3p4p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="4p5p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="5p6p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="6p7p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="7p8p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="8p9p" +/> </td> <td width="6%"><input type="checkbox" name="Monday" value="9p10p" +/> </td> </tr>
Thanks again to those who took the time to comment on this.# Extract and display a summary of information from the form. my @days = qw(Monday Tuesday Wednesday Thursday Friday Saturday Su +nday); foreach my $day (@days) { my @times = $request->param($day); # Count the number of days the user selected something if(scalar @times) { $count += @times; } # Pretty up time times foreach(@times) { s/(\d{1,2}[ap])(\d{1,2}[ap])/\1-\2/; s/(a|p)/\1m/g; } # Display the list for each day $page .= "$day: " . (scalar @times == 0 ? "None" : "@times") . + $request->br(); } # Show the total number of hours selected in the summary $page .= $request->p() . "Total Hours Selected: $count" . $request +->p();
MrCromeDome
|
|---|