[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Get the ID value of a form tag on submit

Hi All

How can get the “ID value” of a form tag on submit.

INCOMING HTML FORM TAGS:
<INPUT ID="5625" Name="QualityItem1" Type="Radio" Value="Poor">
<INPUT ID="5650" Name="QualityItem2" Type="Radio" Value="Good">
<INPUT ID="5675" Name="QualityItem3" Type="Radio" Value="Excellent">

RETURNED VALUES WANTED:
ID|5625|QualityItem1|Poor
ID|5650|QualityItem2|Good
ID|5675|QualityItem3|Excellent
0
blnukem
Asked:
blnukem
1 Solution
 
ZiaTioNCommented:
A couple of things,

You can get the id tag value by appening it to the value tag and then split it when you receivbe it on the other end.

Ex:
<INPUT ID="5625" Name="QualityItem1" Type="Radio" Value="Poor::5626">

Script:
my ($val, $id) = split(/\:\:/, param('QualityItem1'));

There is no direct way to obtian that value through CGI.pm or even using $ENV{'QUERY_STRING'}.  This is due to the way both these methods receive this data.  Basic html parameter passing is done in a key, value pair encoded in the url (?key=value&key2=value2).  The "name" attribute is the key and the "value" attribute is the value.  The id attribute in a form element is for CSS type formatting.

Second, you are using radio buttons and have the names different in all objects.  Radio buttons are designed to represent the same name parameter and only allow a single one checked at a time.  If this is not the effect you are going for you should use checkboxes.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now