in reply to Re: Re: Re: Checkbox values
in thread Checkbox values
BUT... it is SO worthwhile getting through the pain barrier. It's seldom as tough as it looks, and once learned it saves time after time.The optional fifth argument is a pointer to an associative array relating the checkbox values to the user-visible labels that will be printed next to them (-labels).
what it means is "set up a hash where the keys are what you want as the checkbox values, and the values are what you want the user to read" - i.e. something like:a pointer to an associative array relating the checkbox values to the user-visible labels
Now, to avoid confusion, you should probably construct your array of checkbox values from this hash - that way you're sure there's always going to be a match between the values and the labels. So domy %checkbox_items = ( a => 'BillJ may have been assigned as trustee to the security obje +ct which gives him supervisor rights over all NDS objects', b => 'BillJ may be wearing pink pyjamas when he comes round the mo +untain', c => 'BillJ may be the first man to orbit Mars on a unicycle', d => 'BillJ may be just another Perl hacker', );
Then you put it all together by adding the -labels argument when you call the checkbox_group method:my @checkbox_values = keys %checkbox_items;
And this will print out the following HTML (line breaks added for clarity:print start_html, checkbox_group( -name => 'testing', -values => \@checkbox_values, -linebreak => 1, -labels => \%checkbox_items, ),
Hope that does what you want to do in an intelligible way. One other thought - about saving memory. A point frequently made round here, for example by by dragonchild, is that Perl is optimised not for CPU or memory use, but for that scarcest and most valuable of computer consumables... developer time. I.e. YOUR time. So if a thing is quicker to write but slower to run, write it that way and then $RAM->buy('more');<input type="checkbox" name="testing" value="a" /> BillJ may have been assigned as trustee to the security object which g +ives him supervisor rights over all NDS objects <br /> <input type="checkbox" name="testing" value="b" /> BillJ may be wearing pink pyjamas when he comes round the mountain <br /> <input type="checkbox" name="testing" value="c" /> BillJ may be the first man to orbit Mars on a unicycle <br /> <input type="checkbox" name="testing" value="d" /> BillJ may be just another Perl hacker <br />
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Checkbox values
by chriso (Sexton) on Nov 20, 2001 at 01:50 UTC |