Forum Moderators: open
I have 2 forms on one html page. The main form is supposed to be submitted to our email autoresponder (IContact) and the secondary form is supposed to be submitted to a custom php page I created.
Both forms have pretty much the same fields. I created a function that runs when the onSubmit event is triggered for the main form. In that function, I set the values of the secondary form fields to be the same as the main form like this:
"document.mainForm.name.value=document.secondaryForm.name.value;"
At the end of the function, I do a "document.secondaryForm.submit();", which is supposed to submit the secondary form's values to a php page I created that writes the values to a text file(delimited by tabs). Once the form is submitted, I return true(if everything validates correctly), which should submit the main form. Unfortunately, I can get the secondary form to submit to my custom php page ONLY if the main form is not set to submit to anywhere.
I was under the impression that I could submit the seconary form programatically, and still have the main form submit if the onSubmit event's function returned true. It seems I may be mistaken and that only one form may be submitted from a page? If that's the case, then is there a way to actually get this to work (maybe some snazzy ajax magic?)?
Any help I can get on this would be greatly appreciated.
Thanks!
So do you know if submitting a form through an onSubmit event function of another form even works? I'm wondering if maybe I'm just doing it wrong. I guess I could understand why it won't work AND why it should.
<form id="order_form" METHOD="POST" ACTION="http://example.com/POST1" onsubmit="Spry.Utils.submitForm('order_form', '',{method:'post', url:'http://example.com/POST2', async:false});"
<input type="text" name="formField" value="" />
<input type="submit" value="Submit" />
</form>
This form will submit to http://example.com/POST1 as defined in the ACTION attribute and it will post to http://example.com/POST2 as defined in onSubmit.
This example is using the Adobe Spry Ajax library which is still in a pre-release but is stable and I have been using it with great results.
You can get it here:
[labs.adobe.com...]
If you have any question let me know.
[edited by: Demaestro at 9:20 pm (utc) on Oct. 21, 2008]
Here's the form tag I'm using:
<form id="formContact" name="formContact" method="post" action="http://app.icontact.com/icp/signup.php" onsubmit="Spry.Utils.submitForm('formContact', '',{method: 'post', url:'http://www.myDomain.com/processForm.php', async:false});">
and I'm referencing these two js files:
<script src="/js/spry/SpryData.js" type="text/javascript"></script>
<script src="/js/spry/SpryDOMUtils.js" type="text/javascript"></script>
The spry demo at [labs.adobe.com...] has an example that submits a form and references SpryData.js and SpryUtils.js. I could not find SpryUtils.js with all of my other spry files that were installed with Dreamweaver, so I figured SpryDOMUtils.js would work instead.
Any idea where I'm going wrong?
Thanks!