birwin
asked on
Submit two forms on one page
I have two forms on a page. One is a PayPal form that submits information to PayPal, so the customer can complete the purchasee. The other form is sent to my server, to a php program that puts the user and sale information into a database. The second form has some input fields that the customer completes with their name and contact information as well as several hidden input fields.
I am using the following jquery code to populate the first form with the values entered into the second form. The code below works in transfering the values from myForm2 to myForm1, and the form is successfully sent to PayPal with the information.
But the second form, myForm2, does not post.
I am using the jquery.forms plugin, but I am open to any way the keeps the functionality of populating myForm1 with the myForm2 entries, and posts both forms.
<script type="text/javascript" src="js/jquery.forms.js">< /script>
<script language="javascript">
$(document).ready(function () {
$("#button1").click(functi on() {
var First_Name2 = $("#First_Name").val();
$("#first_name").val( First_Name2 );
var Last_Name2 = $("#Last_Name").val();
$("#last_name").val( Last_Name2 );
var Email2 = $("#Email").val();
$("#email").val( Email2 );
var Cell_Phone2 = $("#Cell_Phone").val();
$("#night_phone_a").val(Ce ll_Phone2) ;
$('#myForm1').submit(funct ion() {
var options = { "success":function() { $("#myForm2").submit(); }}
$(this).ajaxSubmit(options );
return false;
});
});
});
</script>
I am using the following jquery code to populate the first form with the values entered into the second form. The code below works in transfering the values from myForm2 to myForm1, and the form is successfully sent to PayPal with the information.
But the second form, myForm2, does not post.
I am using the jquery.forms plugin, but I am open to any way the keeps the functionality of populating myForm1 with the myForm2 entries, and posts both forms.
<script type="text/javascript" src="js/jquery.forms.js"><
<script language="javascript">
$(document).ready(function
$("#button1").click(functi
var First_Name2 = $("#First_Name").val();
$("#first_name").val( First_Name2 );
var Last_Name2 = $("#Last_Name").val();
$("#last_name").val( Last_Name2 );
var Email2 = $("#Email").val();
$("#email").val( Email2 );
var Cell_Phone2 = $("#Cell_Phone").val();
$("#night_phone_a").val(Ce
$('#myForm1').submit(funct
var options = { "success":function() { $("#myForm2").submit(); }}
$(this).ajaxSubmit(options
return false;
});
});
});
</script>
ASKER
Thank you for the code. Unfortunatley it isn't producing the desired result.
Form 1 is a PayPal code that has to be submitted to PayPal, not using AJAX, as the client needs to complete the resulting PayPal forms.
myForm2 should be an AJAX posting to my server.
With your code the myForm2 is the page the client gets, but it is blank, since it only progesses the information. I need the myForm1 result (PayPal) to be shown to the client, and the myForm2 to be handled as an AJAX call to the server.
Form 1 is a PayPal code that has to be submitted to PayPal, not using AJAX, as the client needs to complete the resulting PayPal forms.
myForm2 should be an AJAX posting to my server.
With your code the myForm2 is the page the client gets, but it is blank, since it only progesses the information. I need the myForm1 result (PayPal) to be shown to the client, and the myForm2 to be handled as an AJAX call to the server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi sjklein42:
I tried adding the target, but it made no difference.
For access to the the problem page, please go to Link to Problem This is an indirect link, since it is a client site.
I tried adding the target, but it made no difference.
For access to the the problem page, please go to Link to Problem This is an indirect link, since it is a client site.
I don't think I can help. A bit too complicated for me to unravel. Tried. Sorry.
ASKER
Thank you for your help. I ran the code through the W3 validator, and found some errors. I tinkered with the jQuery code and finally got it to work, although I am not sure which of the fixes I made solved it. But if it works, it works, and I am happy.
Open in new window