Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
For those who may find my end solution helpful, I have posted the code that I have actually used in my project. I thought the reponses given to me were very informative and well thought out, and am very grateful for receving them. I ended up taking a couple of ideas, namely from jeffa and oknow, and from a follow-up chat with tilly. I let my friend do all the HTML design work on this one, and in the end we made a template of the form. As pointed out by ChrisR, the checkboxes in the sample form were named the same, so she cleaned them up and we had a sample form that resembled this:
<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>
Each day was passed to my Perl script as an array of checkboxes. Reading and parsing them as parameters was then as easy as:
# 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();
Thanks again to those who took the time to comment on this.

MrCromeDome


In reply to Re: Converting large numbers of checkboxes to small number of params by MrCromeDome
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? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2022-12-05 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?