Multiple CGI forms on one page

K

Keflavich

I'm trying to make a page that effectively has a menu to choose two
options. The first, it uploads a file, reads it, compares it to
another file on the host computer. The second, it opens up a new form
on the same page to input data and compare to the same file on the
host computer.

Currently, the first option works great. The second option does
create the additional form, but when I submit the second form the page
clears back to its original state. Of course, this makes some sense
to me, seeing as I'm posting only the contents of the second form, but
I hoped there was a way around it.

I'm also trying to dynamically create portions of the page - i.e., one
button outputs some data that includes other buttons, which, when
clicked, would "expand" and show more data.

My description above is pretty vague, so I'm sure I'll need to clarify
some; I don't think I have a great grasp of the terminology. But I
think a simple question to answer would be, "How do you have a second
form submit (POST) all parameters from previous forms when it must be
a separate form?"

I tried searching the forums and google for some answer, but I have no
idea what exactly I'm searching for. I'd be happy with some good
links describing how to do this. BTW, I'm using CGI.pm.

Thanks,
Adam
 
G

gf

I'm trying to make a page that effectively has a menu to choose two
options. The first, it uploads a file, reads it, compares it to
another file on the host computer. The second, it opens up a new form
on the same page to input data and compare to the same file on the
host computer.

Currently, the first option works great. The second option does
create the additional form, but when I submit the second form the page
clears back to its original state. Of course, this makes some sense
to me, seeing as I'm posting only the contents of the second form, but
I hoped there was a way around it.

I'm also trying to dynamically create portions of the page - i.e., one
button outputs some data that includes other buttons, which, when
clicked, would "expand" and show more data.

My description above is pretty vague, so I'm sure I'll need to clarify
some; I don't think I have a great grasp of the terminology. But I
think a simple question to answer would be, "How do you have a second
form submit (POST) all parameters from previous forms when it must be
a separate form?"


It sounds like you'll need to look into the CSS "display" attributes,
or the Javascript equivalents that toggle those settings in the page's
DOM.

The "Dynamic HTML" book covers all that. Or, you can wander over to
the comp.lang.javascript or comp.infosystems.www.authoring.stylesheets
newsgroups and ask there. Or, use "the google" or wikipedia to search
for more info. It's a common task, but has lots of little gotchas
depending on your page design, so you'll do better going to those
experts as this isn't really a Perl or CGI.pm issue.
 
K

Keflavich

The following PM node may be of some interest to you:

Thanks Michele, I think that's what I'm looking for, especially this
reply: http://perlmonks.org/?node_id=597320. I'm not sure how I
missed perlmonks in my previous searches.

gf - I'll try using dhtml or stylesheets if this fails, but I don't
think that's the solution I'm looking for. Besides, I haven't used
stylesheets for over a year and I don't want to relearn them right
now.

Sherm - the simple example definitely isn't want I'm looking for; my
output page includes a new form that disappears when I submit it. I
also don't understand the statement, "That is, the value element or
contents of the created form element will be that of the incoming
parameter of the same name," at least not in context. Certainly, the
values in any form I submit will be readable with
param('parameter_name'), but what about the forms I submitted the
first time?

Thanks for the help,
Adam
 
X

xhoster

Keflavich said:
I'm trying to make a page that effectively has a menu to choose two
options. The first, it uploads a file, reads it, compares it to
another file on the host computer. The second, it opens up a new form
on the same page to input data and compare to the same file on the
host computer.

Currently, the first option works great. The second option does
create the additional form, but when I submit the second form the page
clears back to its original state. Of course, this makes some sense
to me, seeing as I'm posting only the contents of the second form, but
I hoped there was a way around it.

I have a lot of programs that look something like this
(in highly compacted and simplified form):

unless ($q->param('step_1')) { # haven't done step 1 yet
print whatever_form__for_step1();
exit;
};
print $q->hidden('step_1'); # save step 1


unless ($q->param('step_2') { # haven done step 2 yet
print whatever_form_for_step2($q->param('step_1'));
exit;
};
print $q->hidden('step_2') {

## etc.

Of course, if the form for step_2 doesn't change depending on the input
provided in step_1, then there is no reason for them to be separate steps.


Xho
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top