Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 forms that submit to same script at same time on one page

Status
Not open for further replies.

wiser3

Programmer
Jun 3, 2003
358
CA
We're desinging a page with a large form and would like to have a sub-form. Can one submit button submit both forms to the same php script?

The user may fill out the full form and submit it. No problem. But we'd like to have a section of it as a sub-form. So, if they change the sub-form and submit it the server reprocesses the data and returns the page with both the sub-form and larger form filled out as when submitted. A problem arises in that if they submit the sub-form how do we get the data from the large form to the server so we can repopulate those fields.

Perhaps if one form used the post method and the other get? But wouldn't that send two seperate streams to the server the get processed seperately?

Any thoughts or help would be appreciately.

Thanks
 
Is there no way to have it all be one form? I would have the page handler determine what the submission was intended to do based on the fields filled out and the Submit button pressed...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
The one form would about 200 fields, but once populated only a small portion of it would change each time the user returns. We'd like to be able to have that small area update on it's, and have the whole thing updated only when needed.
 
I don't see a problem with what you want to do, but if the sub-form doesn't send all of the fields, then when the page is rewritten after the sub-form processing is done, how are you going to keep the values in the majority of the fields that are NOT submitted for processing? Remember that the entire page is recreated when any form on the page submits.

If you're really serious about doing this, it sounds like an ideal use of an iframe. If the sub-form sits in the iframe, it can submit itself and recreate just the iframe - the rest of the page/form will remain untouched.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
tsdragon - brilliant!

i love the iframe idea
 
Why not just hide the part of the form you dont want to update?
 
In the rare occasion that they need to change something, how do they do it?
 
Hiding the part of the form you don't want to update is useless, hidden forms get submitted anyway.

If the case that they need to change something in the larger form, both the larger and the smaller form will have to be submitted and recreated. Make sure the larger form gets done first. The timing of the running and loading of the two will be important! You'll probably have to have some javascript or server-side code to submit the smaller form for reloading. It could be done by having the server-side code create and insert the query-string required to recreate the page in the iframe, or by having a javascript onload function fill out the (initially blank) subform and submit it to be regenerated.

Does that make sense?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
yes, we were thinking along the sames lines. If someone clicks the submit button in the iframe only it's data is sent and updated.

If someone hits the main submit button a javascript function is called to submit both forms. Were just not sure not how to make sure the outer page is served before the iframe page.

Right now i'm thinking the server writes the iframe page to a file. Then when the main page is loaded it links to that iframe page file and loads it in. Does that sound possible?

Hmm... i think we'll be thinking about this for a while.
 
I still dont understand why you need two forms. Why not use JavaScript to just submit the info you want?
 
Because no matter how much information you SUBMIT, the ENTIRE PAGE will be recreated when the form submit is done. That means that ALL the data in the page will have to be sent to the server and back again to make sure that it is all there on the new page.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top