我的HTML脚本
<HTML>
<BODY>
<H3> Test </H3>
<FORM ACTION=test.pl METHOD=POST>
<p>Please Enter Your Name: </p>
<INPUT TYPE=TEXT NAME="name">
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
我的Perl脚本:
use CGI;
my $q = CGI->new;
my $m = $q-> param("name");
print "<html>";
print "<body>";
print "<head><title>form test</title>";
print "</head>";
print "<body>";
print "<form method=POST action=test.pl>";
print "<p>First value: </p> <input type = text name = fst>";
print "<p>Second value: </p> <input type = text name = scd>";
print "<input type = submit>";
print "</form>";
my $fname = $q->param("fst");
my $fname2 = $q->param("scd");
my $tot = $fname+$fname2;
print "<h2> hi $m your total value is: $tot</h2>";
print "</body>";
print "</html>";
输入名称并提交表单后,Perl CGI脚本显示:
hi /name/ your total value is:
输入输入并提交此表单可以成功运行,但不会显示名称:
hi your total value is: /value/
每次提交第二个表单时如何显示名称?
答案 0 :(得分:1)
一种方法是将hidden input添加到第二个表单,其中name
属性与第一个表单中的相同:
print "<input type='hidden' name='name' value='$m' />";
隐藏的输入不会显示给用户,但会与其他表单字段一起提交。