print button(
-name =>'GOOD',
-value =>'GOOD',
-onclick=>'redirect_GMM()'
);
sub redirect_GMM()
{
print redirect(-url=>'http://localhost/cgi-bin/GMW/GMM.pl');
}
我想通过使用perl中的onclick单击按钮来重定向页面。
print "User name:\t";
print $q->textfield(
-name => 'UserName',
-value =>'Google',
-size => 15,
-maxlength =>25,
);
my $uName = $q->param('UserName');
print "<script>alert($uName)</script>";
没有获得文本字段的值。
答案 0 :(得分:0)
Using the javascript in Perl we can redirect the page from perl file to the another perl file
Step 1 use CGI qw(:standard);
Step 2 my $JSCRIPT=<<EOF;
function redirect_GMM()
{
window.location.href = 'http://localhost/cgi-bin/GMW/GMM.pl';
}
EOF
;
Step 3 my $q =CGI->new;
print $q->header('text/html');
print $q->start_html(-title=>'JJ',-script=>$JSCRIPT);
print $q->h5('JJ login page');
print $q->end_html;
Step 4 print button(
-name =>'GOOD',
-value =>'GOOD',
-onclick=>'redirect_GMM()'
);
This code will surely redirect the page when you press the button.