http://qs1969.pair.com?node_id=272827


in reply to Converting large numbers of checkboxes to small number of params

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