Skip to content Skip to sidebar Skip to footer

Two Different Actions On Form Submit

I have a form with a submit button. I have called a function on click of submit button. function actionPage(form1) { form1.action='action1.php'; form1.submit(); return(true);

Solution 1:

you cannot do it using simple form post submit. but you can do it using AJAX.

as you soon as you call submit() fn, the data from the form is posted to the action url page. hence you might end up page being loaded.

Solution 2:

You cannot. You could submit data to multiple places using an XmlHttpRequest.

Solution 3:

You can't submit the form that way to multiple places. You can do it on the client side via AJAX, or you can post can have the form post to a page that will submit the data wherever else it needs to go. With the AJAX approach, you will run into problems submitting to a different domain due to the same origin policy. I would suggest using cURL on the server side to send the data to other domains.

Solution 4:

Just as simple as this:

<formname=f1type=postaction=''><inputtype='submit'value='first url'onclick="f1.action='/save'"><inputtype='submit'value='second url'onclick="f1.action='/process'"></form>

Taken from: http://www.plus2net.com/html_tutorial/submit-two.php

Post a Comment for "Two Different Actions On Form Submit"