Posting to more than one file...

Posted on 2002-03-05
Last Modified: 2012-05-04

I need to know if it is possible to send the form inputs to
two files (instead of posting them only to one file?

let's assume that i have a form with:
3 one-line text area
3 scrolling text area
1 checkbox

How can i post ALL form inputs to file1.cgi   and
post only 2 one-line text area & 1 checkbox to file2.cgi

can this be done?


Question by:mary_M
  • 4
  • 2
  • 2
  • +2
LVL 10

Expert Comment

ID: 6841313
LVL 10

Expert Comment

ID: 6841540
LVL 10

Expert Comment

ID: 6841543
I'm not working whith javascript for some time but you can assign values to variables and submit to diferent forms.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Expert Comment

ID: 6841626
this problem crops up from time to time.  The bottom line is that an action statement within a form can only have one script to execute.  

What is possible is to call a javascript routine within the action statement and get javascript to submit multiple forms, but this gets messy, although if your carefull its a valid option.

What most developers will do is store all the info in one form and call different perl scripts which different processing, but the choice is your yours.

for good javascript examples:

let me know if you need more help....

LVL 16

Expert Comment

ID: 6842095

"..How can i post ALL form inputs to file1.cgi   and
                     post only 2 one-line text area & 1 checkbox to file2.cgi...."

What exactly do you mean by post form inputs to 2 files?
The files you are referring to are CGI programs.

Can you pl. explain, in plain english, what each of these scripts will do when they receive the inputs?
Can you post any relevent URL that has the HTML form that you are talking about?

"..can this be done?..."

Technically, there is always a solution. So i a optimistic that you can get a satisfactory answer, provided you provide more detail around your exact requirements.

Let me know.

LVL 19

Expert Comment

by:Kim Ryan
ID: 6842495
As peewee says, a form can only have one associated action, or script to be executed on submission. Can you use 2 forms instead? A workaround is to have all paramters passed to your submit script, called say file1.cgi. Then let file1.cgi call file2.cgi, passing all the form paramters to it AND then call file3.cgi, just passing the parameters for the 2 one-line text areas & 1 checkbox.

Author Comment

ID: 6843663
Hi everybody...

someone told me that this can be done by JS (as you all

" putting an onSubmit="..." attribute into the
<form... tag.

The onSubmit causes a JavaScript function to load and
run the file, when done, returns  true.

The JavaScript function could launch a popup that runs
a script and  closes automatically after the script has

Well, but i still don't know how to do this?!

Here is the whole story (for maneshr   and others who
requested more info):

I currently have a form that takes all data (upon
pressing sunmittion) and stores all values in an SQL DB

I didn't do that form... but it is working without any

ok the fileds are:
Brief Describtion:
Newsletter?:   (a check box, once checked the submitter
is going to get a newsletter to his email).

What i need.. is to leave everything is it working
now... i.e. all the above value will go to the DB as


I need to take the values in the name,email and store them in
another separate file like newsletter.txt

In other words...if the checkbox is left checked (default)..
ALL inputs will go to the DB... AND name/email fileds only will
also be stored into a file: newsletter.txt
(or whatever the name is).
LVL 10

Expert Comment

ID: 6843834
first of all, can't you do that in just 1 script.

you maybe can do that in other way. You first call your script that put your data in the "newsletter.txt" if need. Your script creates a new page whith just a form that have hidden fields and in js you submit that form to your old script.

your first script generate something like

  <form method="POST" name='xpto' action="">
   <input type="hidden" name="Name" value="xxx">
  <SCRIPT LANGUAGE="JavaScript">

and your old script shell work OK.
LVL 19

Expert Comment

by:Kim Ryan
ID: 6845403
Maybe you should raise this question in the javascript area.

Accepted Solution

Peewee earned 150 total points
ID: 6846952

have a look at the following links this covers your question:


Author Comment

ID: 6850796
Peewee  ..

YES.. these are *exactly* what i needed.

One question: How did you locate these two answers in that webste... the website is too big.. so what words did you use to search for?


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hard perl script 16 158
Can Oracle Client work with an Oracle 12c Database? 5 164
How to get all the API from website? 11 104
Call Shell Script from Perl Script 6 134
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

838 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