perl CGI单选按钮表单

时间:2016-03-10 22:39:21

标签: forms apache perl cgi

我的代码中有以下CGI代码段。它创建textarea来键入我要发送的消息,但是我想将其转换为模板样式,如" radio",所以我只选择单选按钮,它会将任何消息注入客户的通知中,所以我不需要每次都输入消息。就像模板一样。任何人都有任何可以修复我的要求的例子或代码?

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;

1 个答案:

答案 0 :(得分: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,
);