使用Perl表单 [英] Using Form with Perl

查看:71
本文介绍了使用Perl表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个新项目。我创建了一个Excel文件,根据某人的位置和电力消耗来计算太阳能需求。它很好用。


现在我想从这个文件中创建一个HTML模型。


日照信息将存储在一个单独的文件。用户必须向我提供计算开始的城市。


我不知道如何使用< FORM>在Perl中标记以接受来自用户的输入。用户需要输入的第一件事是城市。我不知道该怎么做ACTION?

展开 | 选择 | Wrap | 行号

解决方案

action属性需要指向表单处理脚本。


脚本将解析表单提交字段,并根据表单提交中传递的值执行所需的子句。


嗨Ron,


子例程在同一个脚本中。我怎么称呼呢?我尝试了通常的方法,即action ="& Sub_Name;"但它不起作用。


有什么想法吗?


谢谢,


Yves


你在哪里知道


action ="& Sub_Name;"



是通常的方式?


action属性需要/需要一个url,而不是一个perl子程序调用。网址可以是相对网址或绝对网址。
http:/ /www.w3schools.com/tags/att_form_action.asp


如果省略action子句,则默认将表单数据发送到生成的同一脚本表单即ie本身。


脚本需要解析表单提交,然后执行Search_City_information子例程,将表单提交中检索到的城市传递给它。

假设表单处理脚本名为CitySearch.pl,则action属性为:


< form method =" POST"行动= QUOT;的cgi-bin / CitySearch.pl">



如果它使用CGI模块解析表单提交,你可以这样做:

展开 | 选择 | Wrap | 行号< /跨度>

Hello,

I have a new project. I created a Excel file that calculate Solar Power requirement base on someone location and electric consumption. It works nicely.

Now I want to make a HTML model inspired from this file.

The Insolation information would be stored in a separate file. The user will have to provide me with it''s city for the calculation to commence.

I don''t know how to use the <FORM> tag in Perl to accept input from users. The first thing the user need to input is the city. I don''t know what to put for ACTION ?

Expand|Select|Wrap|Line Numbers

解决方案

The action attribute needs to point to your form processing script.

The script will parse the form submission fields and execute the required sub based on the values passed in the form submission.


Hi Ron,

The sub routine is in the same script. How do I actually call it? I tried the usual method, i.e. action = "&Sub_Name;" but it does not work.

Any idea ?

Thanks,

Yves


Where did you get the idea that

action = "&Sub_Name;"

is "the usual way"?

The action attribute expects/requires a url, not a perl subroutine call. The url could be either a relative or absolute url.
http://www.w3schools.com/tags/att_form_action.asp

If you leave out the action clause, then it defaults to sending the form data to the same script that generated the form i.e., itself.

The script would need to parse the form submission and then execute the Search_City_information subroutine passing it the city retrieved from the form submission.

Assuming the form processing script is called CitySearch.pl, the action attribute would be:

<form method="POST" action="cgi-bin/CitySearch.pl">

and if it is using the CGI module to parse the form submission, you could do something like this:

Expand|Select|Wrap|Line Numbers


这篇关于使用Perl表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆