Handling multiple forms with same name hidden fields
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Handling multiple forms with same name hidden fields
I've been working on this cgi script and encountered a problem.
Basically, i have a script (Perl CGI) that prints a page with 2 forms both with a submit button and having each a hidden field with the same name, but different value.
The problem is that when ever i press either submit button the hidden field (because of the same name) get's overwritten by what ever hidden field was submitted to the script in the URL (get method).
Specify your script name as the action for the form. This will overwrite the default action which will include the query string the script was called with. I'm not used to using the CGI library htat much so post the actual html output (that is the important bit) If what I said is wrong or doesn;t make sense.
I think i've come up with a decent solution:
name the hidden fields in a sequential manner (so they all have a different name), then to extract the values, loop, untill you find a submitted param.
So if i have 2 hidden fields "h1" and "h2", etc... then to find that h2 was actually submitted i would loop through with param("h" . $count) untill i find something (with $count incrementing each time).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.