| 7:02 am on Jul 16, 2002 (gmt 0)|
Something like onClick="CheckForms()"; to initiate the process.
Use the CheckForms() function to verify all your data is correct.
to submit your forms.
Try this [w3schools.com] as a starting point.
Hope that's of some help.
| 1:05 pm on Jul 16, 2002 (gmt 0)|
The above suggestion doesn't work, because once a form is submitted, focus leaves the document.
Another method is to have the second form on a second page which has the submit routne on the onLoad method. The page never really shows, it appears that the final page loads twice.
| 1:33 pm on Jul 16, 2002 (gmt 0)|
A good point and well made ;-)
| 5:44 pm on Jul 16, 2002 (gmt 0)|
I dont understand why have you split the form?
Have you set enctype=multipart/form-data
Request all the form fields on the server with the upload object and then do what you want with them.
| 5:55 pm on Jul 16, 2002 (gmt 0)|
I would just make it one form and then let your script that handles the form sort out what to do with everything.
Send all your values to your script let it drop all appropriate values into the DB and then send off the doc and throw up a thankyou page or whatever happens next.
If the two forms must be submitted together 100% of the time it would only make sense. I would think you could combine your two scripts together with only mild difficulty making sure they don't step on each others toes.
| 6:05 pm on Jul 16, 2002 (gmt 0)|
I am inclined to agree with jatar_k, one form would be the way to go. It would be nice to know what server side scripting you are using.
| 12:04 am on Jul 17, 2002 (gmt 0)|
I do see that sometimes it is necessary to be able to post two forms simultaneously, especially in the environment where two forms are independent. For example, trying to integrate two different web applications, and both of them have forms on different parts of the page... There are at least two possible ways that I can think of.
<iframe name="dummy" width="0" height="0"></iframe>
document.Form1.target = 'dummy';
- Harvest data from these two forms by traversing through form.elements, and then encoded them into a string suitable for POST request. Hint: use encodeURIComponent().
- Create a XmlHttpRequest object, i.e.
var obj = document.all ? // Check whether it is MSIE
new ActiveXObject("Msxml2.XMLHTTP") : // MSIE
new XMLHttpRequest(); // Mozilla
- Use the object to do the POST request! Then you need to check the readystate to make sure the request has completed. You can then display a thank you message, or redirect to another page when both forms are posted.
As you can see, it only works for MSIE > 5 and Mozilla. But who cares about other players anyway :)
| 8:42 pm on Jul 17, 2002 (gmt 0)|
Thanks everyone for your suggestions particularly scotty. Essentially I followed your advice concering submitting the first form to a hidden frame and it works perfectly.