Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Novice - Submit to different scripts

0 views
Skip to first unread message

Lew903

unread,
Oct 4, 2002, 8:31:44 PM10/4/02
to
First off, let me apologize if my questions are posted in the wrong
forum, I've used the wrong terminology/jargon, etc. This is my first
endeavor with perl.

Over the last 2 weeks, with much perusing the perl, etc. groups, I've
been able to put together a website project that contains a lengthy 8
page questionnaire form. Using hidden fields to carry the previous
form user-filled-in info forward to the next html form after clicking
a Continue button, a Submit button in the final form writes the
information to a simple log. Eventually a database will replace the
log. So far I have been able to generate the new html form(s) and
write to the file successfully using perl example scripts I've found
and adapting them for this project.

Everything works beautifully... but now a at-first-glance simple
change to this project has stopped me cold. What I need to do now is
have 2 sets of radio buttons in the first html form (1st set - married
or single, 2nd set - retired or not retired) and depending on the
radio buttons selected, would call the appropriate script that
generates the appropriate html form.

For example, when the "Married" and "Retired" radio buttons are
selected and the Submit button is clicked, the generated html form
that follows would be one I've put together that has the first form
info in hidden fields and has only new questions that pertain to a
married, retired user.

The first html form contains only "common"-to-all-users questions and
when submitted, the following html form would present the next
"customized" set of questions I've put together. The appropriate html
forms 3 thru 8 would follow at each Continue button click (similar to
the scripts that generate each html form now). The rub is the split
at the first html form based on which of the four radio buttons are
selected.

I respectfully ask for your suggestions on a method for getting one
Submit (Continue) button to call different scripts based on
conditionals. I'd like to do this without using JavaScript in case
it's disabled or multiple Submit buttons on the first html form. I'd
like to avoid the alternative of using a first html page where the
user selects their status by clicking on a link to a whole set of
customized html forms.

The first thing that comes to my uneducated mind is have the submit
button call an intermediate script that calls the appropriate script
based on the radio buttons selected. Other questions, such as what to
do about responding to the browser in the intermediate script, have me
at a loss at this point.

Again, my apologies for my (hopefully temporary)ignorance, wrong group
post, and a too long/basic description of what I trying to do, etc.
I've gleaned the Perl books I've just bought, searched the news
groups, etc. before I posted, but haven't found this exact topic.

Any input much appreciated, Lewis

Mark

unread,
Oct 4, 2002, 10:04:08 PM10/4/02
to
<Snipped for brevity>

>
> I respectfully ask for your suggestions on a method for getting one
> Submit (Continue) button to call different scripts based on
> conditionals. I'd like to do this without using JavaScript in case
> it's disabled or multiple Submit buttons on the first html form. I'd
> like to avoid the alternative of using a first html page where the
> user selects their status by clicking on a link to a whole set of
> customized html forms.
>
> The first thing that comes to my uneducated mind is have the submit
> button call an intermediate script that calls the appropriate script
> based on the radio buttons selected. Other questions, such as what to
> do about responding to the browser in the intermediate script, have me
> at a loss at this point.
>
> Again, my apologies for my (hopefully temporary)ignorance, wrong group
> post, and a too long/basic description of what I trying to do, etc.
> I've gleaned the Perl books I've just bought, searched the news
> groups, etc. before I posted, but haven't found this exact topic.
>
> Any input much appreciated, Lewis

The first page submission is delivered to script 1 which delivers whichever
second page is appropriate to the radio buttons selected and changes the
form action attribute to send all further submits to the appropriate script
to deliver pages 3-8. Since all data on page one is required by both
scripts, is returned with page two in hidden fields, and page two is
customized with the appropriate form attributes to invoke the proper script
thereafter, it should work fine. Right?

Simply, page 1 is interpreted by script one to customize the form action
attribute of all subsequent pages to run script two for married, or script 3
for retired.

HTH,
Mark


Alan J. Flavell

unread,
Oct 5, 2002, 7:32:12 AM10/5/02
to
On Oct 4, Lew903 inscribed on the eternal scroll:

[...sniporama...]

> I respectfully ask for your suggestions on a method for getting one
> Submit (Continue) button to call different scripts based on
> conditionals.

This is a CGI question (such questions would be more on-topic on
comp.infosystems.www.authoring.cgi - check its posting guidelines)
but in fact is an FAQ there.

The answer is that an HTML FORM has an ACTION URL, and that specifies
the process (script etc.) which will field the form submission. That
URL is fixed when the FORM is written, i.e you can configure it on the
basis of what you got from previous forms if you're writing a new form
for each submission cycle, but when your form is written, it's fixed.
What you do in that script is up to you.

> I'd like to do this without using JavaScript

Of course, since javascript is optional..

> The first thing that comes to my uneducated mind is have the submit
> button call an intermediate script that calls the appropriate script
> based on the radio buttons selected.

Bingo. But why do you suppose these have to be different "scripts"
behind such a CGI wrapper? It's only a question of how you organise
your code.

Or are you trying to say that someone has given you some pre-written
CGI scripts and you want to invoke those without modifying them? That
way lies various kinds of maintenance nightmare IMHO.

> Other questions, such as what to
> do about responding to the browser in the intermediate script, have me
> at a loss at this point.

If they do that for you, just how do you suppose your users - who
don't know anything about what's going in behind the scenes - are
liable to be confused? Many, many forms-based procedures on the WWW
have (in my observations) been cobbled-up in a way that thoroughly
confuses the user (not only simple things like demanding yes/no
answers to questions that are not applicable; ZIPcodes in USA format
for Canadian applicants; insisting that European users enter their
phone number as 1-xxx-xxx-xxxx), and suggests that their author was
even more confused than the user about what they were implementing.

Don't over-reach yourself: my advice would be to implement something
simple that's comfortably within your capabilities, then at least it
should have a chance of not painting the user into impossible corners.

Have fun.

Tad McClellan

unread,
Oct 5, 2002, 8:25:53 AM10/5/02
to
Lew903 <lsut...@lcsdg.com> wrote:


> I respectfully ask for your suggestions on a method for getting one
> Submit (Continue) button to call different scripts based on
> conditionals.


I suggest that you do not call different scripts
based on conditionals. :-)

> The first thing that comes to my uneducated mind is have the submit
> button call an intermediate script that calls the appropriate script
> based on the radio buttons selected.


Rewrite the "appropriate script"s as subroutines. Have one CGI
program that calls the applicable subroutine(s).


> Other questions, such as what to
> do about responding to the browser in the intermediate script, have me
> at a loss at this point.


You need only send output to STDOUT. If the "appropriate script"
makes the correct output, the browser will be happy, even if
the program was called from within some other program.

It doesn't matter what program makes the output on STDOUT,
only that it gets made one way or another.


> Any input much appreciated, Lewis


Since you mention that you are new to all of this, let me point out
two Very Important Things that you have made no mention of.

Spoofing hidden fields is childishly easy, you better enable
"taint checking" on all CGI programs that accept user input
(hidden fields *are* user input):

perldoc perlsec


You will need to use file locking if you want to avoid corrupted data:

perldoc -q "\block"


--
Tad McClellan SGML consulting
ta...@augustmail.com Perl programming
Fort Worth, Texas

0 new messages