使用Perl CGI参数从选项中获取名称和值 [英] Get both name and value from option using Perl CGI param
问题描述
在我的HTML代码中,我有
< option name =PRODUCTSvalue =3> Products< /选项>
我需要通过我的Perl CGI参数获取服务器端Perl函数中的名称和值。
我只能得到这个值,有没有办法得到这个名字?
< option name =PRODUCTSvalue =3>产品< / option>
< option>
元素不会有一个名称
属性,所以这是无效的HTML,浏览器将忽略它(除非它可能使其可用于JavaScript)。
表单提交后,浏览器将向服务器发送所选选项的名称以及所选选项的值。这是服务器将收到的唯一信息。
如果您想获得'PRODUCTS',那么您需要:
- 将其包含在值中:
value =3-PRODUCTS
然后my($数字,$ word)= split' - ',$ value
- 查找
3
与服务器(例如嵌入脚本中的散列或数据库查询)相关。
In my HTML code I have
<option name="PRODUCTS" value="3">Products</option>
I need get both the name and value values in my server side Perl function through my Perl CGI param.
I can only get the value, is there a way to get the name also?
<option name="PRODUCTS" value="3">Products</option>
An <option>
element does not have a name
attribute, so this is invalid HTML and the browser will ignore it (except that it might make it available to JavaScript).
When the form is submitted, the browser will send to the server the name of the select coupled with the value of the selected option. This is the only information that the server will receive.
If you want to get 'PRODUCTS' then you will need to either:
- Include it in the value:
value="3-PRODUCTS"
and thenmy ($number, $word) = split '-', $value
- Look up the word that
3
is related to on the server (e.g. in a hash embedded in the script, or with a database query).
这篇关于使用Perl CGI参数从选项中获取名称和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!