CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
checkbox_group how to check all values



Jan 16, 2004, 5:43 AM

Post #1 of 2 (718 views)
checkbox_group how to check all values Can't Post


I have been trying for a long time to get all the checkboxes (using in a checkbox_group checked by using the attribute defaults;

checkbox_group(-name=>'studenten_in_groep', -values=>\@member_keys, -defaults=>\@member_keys, -labels=>\%temp_members, -columns=>2)

I can not get this to work, no boxes are checked and there are no errors, it seems to be ignored competely!

When i give the param('studenten_in_groep') a value before i call on the checkbox_group, it does check all the boxes;

param('studenten_in_groep' => @member_keys);

Is it not possible to use the defaults attribute the way i am trying to? If i look at examples on cpan it looks like i am doing it the correct way..

Any ideas?


Thaumaturge / Moderator

Jan 17, 2004, 3:47 AM

Post #2 of 2 (717 views)
Re: [tine] checkbox_group how to check all values [In reply to] Can't Post

What data do you have in @member_keys and %temp_members?

It all seems to work as expected for me.


use strict;
use warnings;

use CGI qw(:standard -no_xhtml);

my @member_keys = 1 .. 5;
my %temp_members = (1 => 'one', 2 => 'two', 3 => 'three',
4 => 'four', 5 => 'five');

print checkbox_group(-name=>'studenten_in_groep',

I get the following output (slightly reformatted for clarity)

<td><input type="checkbox" name="studenten_in_groep"
value="1" checked>one</td>
<td><input type="checkbox" name="studenten_in_groep"
value="4" checked>four</td>
<td><input type="checkbox" name="studenten_in_groep"
value="2" checked>two</td>
<td><input type="checkbox" name="studenten_in_groep"
value="5" checked>five</td>
<td><input type="checkbox" name="studenten_in_groep"
value="3" checked>three</td>

As you can see, all of the checkboxes have the "checked attribute, so they will appear as selected when the page is displayed in a browser.

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives