【问题标题】:perl CGI radio button formperl CGI 单选按钮表单
【发布时间】:2016-06-26 00:32:51
【问题描述】:

我的代码中有以下 CGI sn-p。它创建文本区域来输入我要发送的消息,但我想将其转换为模板样式,如“收音机”,所以我只选择单选按钮,它会将任何消息注入到客户的通知中,所以我不需要每次都输入消息。就像模板一样。有人有任何示例或代码可以解决我的要求吗?

use CGI;
use CGI::Carp;
...
...
$html .= $q->b("Customer Notification:") . $q->br;
    $html .= $q->textarea(-name=>'notification',
                          -rows=>4,
                          -columns=>60) . $q->p;

    $html .= $q->submit(-name=>' Send Notification ');
    $html .= "        ";
    $html .= $q->reset(-name=>' Reset to Original Value ');
    $html .= $q->p;

【问题讨论】:

  • 你似乎在使用 CGI.pm,you shouldn't do that
  • 是的,我已经更新了我的问题
  • Quentin 的观点是不鼓励使用 CGI.pm 并且您正在使用的 HTML 生成函数have been deprecated
  • 这些代码是几年,几年的代码,只需要稍作修改。我们可以从头开始重写它。如果在现有代码中可以实现的话会很好,radio_group 怎么样?

标签: forms apache perl cgi


【解决方案1】:

就像其他人提到的那样,您真的应该考虑使用CGI::Alternatives 中的其他解决方案之一。

不过……

my %labels = (
    'comment'   => 'General Comment',
    'problem'   => 'Non-critical Problem',
    'emergency' => 'Critical Emergency',
);
$html .= $q->radio_group(
            -name=>'notification',
            -values=>['comment','problem','emergency'],
            -default=>'comment',
            -linebreak=>'true',
            -labels=>\%labels,
);

【讨论】:

  • 你的代码看起来不错,但问题是,我有两行电子邮件,我想把它放在那里,如何放在那里,就像We have emergency maintenances which require system down for X to Y time etc..
  • 如果您想将这两行作为表单值提交,只需将其设为其中一个单选按钮的值即可。 -values=>['comment','problem','We have emergency maintenances...'],
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多