CGI:可以将大量单选按钮组值收集到一个数组中吗?
我正在做一个 Perl/CGI 表单,需要向用户呈现可变数量(1 - 100 或更多)是/否单选按钮组。有没有办法必须创建一个单独的变量来保存每个值
$radio1 = $q->param('radio1');
$radio2 = $q->param('radio2');
$radio3 = $q->param('radio3');
,或者我可以将它们存储在某种数组中,例如复选框组值,
@checks = $q->param('checks');
因为单选按钮组都需要有不同的“名称”属性,我不知道认为数组是不可能的。我认为唯一的选择是一次显示固定数量的单选按钮并声明变量来保存每个按钮。
有更多 Perl/CGI 经验的人可以为此提供替代解决方案吗?谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未经测试。类似的东西
可能会有所帮助。
Untested. Something along the lines of
might help.
请参阅 http://search.cpan.org/perldoc/HTML::FormFu 和
http://search.cpan.org/perldoc/Catalyst ::Manual::Tutorial::09_AdvancedCRUD::09_FormFu
并参见
Data::FormValidator
/Data::FormValidator::Tutorial
您创建一个配置文件,formfu 从该配置创建 html(表单),验证表单,无论它们是单选按钮还是其他什么
,或者您创建 formvalidator 配置文件,您创建自己编写 html ,然后让 formvalidator 验证...
也很有趣的是 CGI::FormBuilder (如 formfu)和 HTML::FormHandler (两者都相似,但 moosey )
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 )