Dynamic FORM names

  • Thread starter Juhani Elbanvetäjä
  • Start date
J

Juhani Elbanvetäjä

Hey,
I've been wondering for a while if it is possible to have dynamic form
names..
To make it clear, I've used common parse_form subroutines and then read form
querys:
$form_input = "$FORM{'form_name'}";
Now, when I have manymany checkboxes in my form I need to write every
form_name manually because the code above doesn't quite accept variables as
follows:
$form_input = "$FORM{$form_name}";
no matter whether I use " '' " or not.
I would appreciate a solution for this problem. At the moment I'd like to
think that it lies in the parse_form subroutine...?
 
J

John Bokma

Juhani said:
Hey,
I've been wondering for a while if it is possible to have dynamic form
names..
To make it clear, I've used common parse_form subroutines

That sounds like horrors from the 90's.

use CGI;
$form_input = "$FORM{$form_name}";

my $cgi = new CGI;
$foo = $cgi->param( $bar );
 
A

A. Sinan Unur

I've been wondering for a while if it is possible to have dynamic form
names..
To make it clear, I've used common parse_form subroutines and then
read form querys:

What is a common parse_form subroutine? The only standard way of parsing
CGI requests is with CGI.pm. There is no way for us to know what you are
using to parse CGI requests if you are not using CGI.pm.
$form_input = "$FORM{'form_name'}";

See:

perldoc -q always
Now, when I have manymany checkboxes in my form I need to write every
form_name manually because the code above doesn't quite accept
variables as follows:
$form_input = "$FORM{$form_name}";
no matter whether I use " '' " or not.

Please post a short but complete script illustrating the problem you are
having. Please do read the posting guidelines for this group to learn
how to help yourself and help others help you.
I would appreciate a solution for this problem. At the moment I'd like
to think that it lies in the parse_form subroutine...?

I do not know as I am not sure what the problem is and what parse_form
does.

Sinan
 
G

Gunnar Hjalmarsson

Juhani said:
I've been wondering for a while if it is possible to have dynamic form
names..

Yes, of course.
To make it clear, I've used common parse_form subroutines and then read form
querys:
$form_input = "$FORM{'form_name'}";
Now, when I have manymany checkboxes in my form I need to write every
form_name manually because the code above doesn't quite accept variables as
follows:
$form_input = "$FORM{$form_name}";
no matter whether I use " '' " or not.

Exactly what do you mean by "doesn't quite accept"? Whatever you mean, I
find it hard to believe that you can't access a hash value while
specifying the key as a variable.

our %FORM = ( somename => 'somevalue' );
my $form_name = 'somename';
my $form_input = $FORM{$form_name};
print "$form_input\n";

Outputs:
somevalue

Accordingly, I'd guess that you are making some other mistake.

Please study the posting guidelines for this group:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Doing so you'll see that in order to increase your chances to get help,
you are recommended to post a short but complete program that others can
copy and run and that demonstrates the problem you are having.
I would appreciate a solution for this problem. At the moment I'd like to
think that it lies in the parse_form subroutine...?

If that's actually the case, the only solution to your problem you are
likely to get here is that you'd better start using the more up-to-date
parsing routine provided by CGI.pm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,171
Messages
2,570,934
Members
47,472
Latest member
KarissaBor

Latest Threads

Top