Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found