Thursday, 31 July 2008

Enable an HTML Form to Submit to Multiple Locations Using Javascript

This is a simple solution to allow a single html form to submit to multiple locations.

<form name="myform" method="post" action="noscriptPage.php">
<input type="submit" name="submit" value="Update"
<input type="submit" name="submit" value="Submit"

Add the multiple submit buttons to the form, each with a Javascript onclick clause to change the forms action property, to the desired action page.


Optionally you can also cater for users with Javascript disabled, by adding a default action to the form, to either go to a message page, forward page that can determine the button pressed and forward.

No comments: