I took a look at the web page and noticed one thing up front that will probably cause you some difficulty. Each checkbox has the same name. This will make it impossible to distinguish one from another. Your best be here is to come up with a naming convention for the checkboxes. I would use the day follwed by a delimeter follwed by the hour. For example: monday-7, monday-8 ... monday-16, monday-17, tuesday-7, tuesday-8, etc.

I don't think you will find a way to avoid having a different name for each checkbox. You can still use a loop to create the form quite easily without a lot of code.

Parsing the query string out can be made very simple as well. Try this snippet:
if ($ENV{'QUERY_STRING'} ne '') { # for get requests $webparams = "$ENV{'QUERY_STRING'}"; } else { # for post requests (you should always use post) read(STDIN, $webparams, $ENV{'CONTENT_LENGTH'}); } $webparams =~ s/\&/\n/g; $_ = $webparams; %webparams2 = /^(.*?)=(.*)$/gm;
This will return a hash (%webparams2) containg an entry for every checkbox that was checked when the form was submitted. The keys will be the names of the checkboxes. Now you can just loop through the hash or use map to create your database statement.

I hope this helps. If you would like a more complete example including form generation and db statement preparation, just let me know.

Chris

In reply to Re: Converting large numbers of checkboxes to small number of params by ChrisR
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.