Forum Moderators: open

Message Too Old, No Replies

Submit multiple forms with one submit button

         

jsellnau

2:36 am on Mar 24, 2004 (gmt 0)

10+ Year Member



I am trying to have a submit form from one form perform the submit for a second form as well.

I was wondering if I need to have the active submit button outside of both forms and write a function that will submit both forms at the same time but only take it to the destination of one of the forms and ignore thr forward tag for the other.

This is also all written within a php page.

function PRICE() {

if(document.REQUEST.DOMAINBOX.value == 0) {
var total = new Number(document.REQUEST.TOTAL.value);
document.PayPal.a1.value=total;
document.PayPal.a3.value=total;
document.PayPal.item_name.value="Website Hosting Service";
document.PayPal.item_number.value="00001";

}
else {
var total = new Number(document.REQUEST.TOTAL.value);
var dcost = new Number(35);
document.PayPal.a1.value=dcost+total;
document.PayPal.a3.value=total;
document.PayPal.item_name.value="Domain Webhosting Service";
document.PayPal.item_number.value="00002";
}
document.REQUEST.submit();
}

<form name="PayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onclick="PRICE();">

Do I need to write a seperate functiont that will submit both forms with the execution of the if else statement first.

I am stuck and have been working it on it for about 8hrs.

puresilk

3:28 am on Mar 24, 2004 (gmt 0)

10+ Year Member



jsellnau

I'm not a javascript guru, but I believe theres a couple of ways to do this. You can either call another function from inside your function PRICE() ie once this function has run you include the other function inside the closing brace so they will run in sequence. The other way of doing it is in your form tag where you have OnSubmit= you can have multiple functions seperated by semi colons ie "PRICE(); SECONDFUNCTION();" you could add more to this is you wanted. If you wanted them to go to different destinations then you would have to change the action handler to do something like this.

myform1.action = 'destination1.asp/php'
myform1.submit()
myform2.action = 'destination2.asp/php'
myform2.submit()

Not sure how netscape will deal with the last bit but should work in IE

Hope this helps

Mark

jsellnau

3:11 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



it submits the last form but not the first....

puresilk

6:35 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



Does it only submit 1 form using both methods? It maybe that you are using the second function after the document.REQUEST.submit() which is part of the first function if it is then the second function will never run it will always submit after the first function. You would have to place the second function above the document.REQUEST.submit().