0

I'm doing a Perl/CGI form that needs to present a variable number (1 - 100 or more) of Yes/No radio button groups to a user. Is there any way around having to create a separate variable to hold each value like so

$radio1 = $q->param('radio1');
$radio2 = $q->param('radio2'); 
$radio3 = $q->param('radio3'); 

or can I store them in some kind of array like checkbox group values

@checks = $q->param('checks');

Since the radio button groups will all need to have a different 'name' attribute, I don't think an array will be possible. I think the only option would be to display a fixed number of radio buttons at a time and declare variables to hold each one.

Can anyone with more Perl/CGI experience provide an alternate solution for this? Thanks.

0

2 Answers 2

2

Untested. Something along the lines of

my %radio_groups = map { $_ => $cgi->param($_) } grep /^radio/, $cgi->param;

might help.

Sign up to request clarification or add additional context in comments.

Comments

0

See http://search.cpan.org/perldoc/HTML::FormFu and http://search.cpan.org/perldoc/Catalyst::Manual::Tutorial::09_AdvancedCRUD::09_FormFu

and see Data::FormValidator / Data::FormValidator::Tutorial

you create a config file, formfu creates html (forms) from that config, validates the forms, whether they are radio buttons or whatever

or you create formvalidator profile, you create the html yourself, and let formvalidator validate ...

also interesting are CGI::FormBuilder (like formfu) and HTML::FormHandler ( like both but moosey )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.