Get the ID value of a form tag on submit

Posted on 2006-04-15
Last Modified: 2013-11-19
Hi All

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

<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">

Question by:blnukem
    1 Comment
    LVL 5

    Accepted Solution

    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.

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

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

    There is no direct way to obtian that value through 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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Dreamweaver CC 2015

    Adobe Dreamweaver Creative Cloud is used by web designers and front-end developers and allows you to visualize your site in real-time as you code. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    Suggested Solutions

    Title # Comments Views Activity
    Menu Trouble 8 24
    query of query sort 6 77
    WordPress/WooCommerce security best practices? 2 56
    File names with & character 6 47
    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    The viewer will learn how to count occurrences of each item in an array.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now