Perl脚本在几行上写标签

时间:2015-04-22 18:32:31

标签: perl

所以我的代码就是这个

print "<div id=\"form\">\n";
print "<form name=\"confirm\" method=post ACTION=\"\">\n";

print"<label for=\"name\">Name:</label>\n";
print "<input type=\"text\" name=\"name\" class='forminput' id='name' value=\"$name\">\n";

print"<label for=\"amount\">£:</label>\n";
print "<input type=\"text\" name=\"amount\" class='forminput' id='amount' value=\"$amount\">\n";

print"<label for=\"comment\">Comment:</label>\n";
print "<input type=\"text\" name=\"comment\" class='forminput' id='comment' value=\"$comment\">\n";


print "</form>\n";

输出如下
姓名:[TextBox]£:
[TextBox]评论:
[TextBox]

是否可以编写perl来编写右侧文本框前面的标签?

2 个答案:

答案 0 :(得分:1)

尝试在新行之后的每行之后添加<br>,例如

print "<div id=\"form\">\n";
print "<form name=\"confirm\" method=post ACTION=\"\">\n";

print"<label for=\"name\">Name:</label><br>\n";
print "<input type=\"text\" name=\"name\" class='forminput' id='name' value=\"$name\"><br>\n";

print"<label for=\"amount\">£:</label><br>\n";
print "<input type=\"text\" name=\"amount\" class='forminput' id='amount' value=\"$amount\"><br>\n";

print"<label for=\"comment\">Comment:</label><br>\n";
print "<input type=\"text\" name=\"comment\" class='forminput' id='comment' value=\"$comment\"><br>\n";

print "</form>\n";

希望这有帮助

答案 1 :(得分:1)

这似乎更像是一个HTML&amp; CSS问题,但这可行:

print qq{
<div id="form">
<form name="confirm" method=post ACTION="">
<p><label for="name">Name:</label>
<input type="text" name="name" class='forminput' id='name' value="$name"></p>
<p><label for="amount">£:</label>
<input type="text" name="amount" class='forminput' id='amount' value="$amount"></p>
<p><label for="comment">Comment:</label>
<input type="text" name="comment" class='forminput' id='comment' value="$comment"></p>
</form>
};

您可以使用一些CSS来设置它的样式,这里有一个指南:

http://www.htmlgoodies.com/tutorials/forms/article.php/3888746/HTML-Forms-From-Basics-to-Style-Layouts.htm