Hi I have one html <form>.
The form has only one action=""
attribute.
However I wish to have 2 different target=""
attributes depending on which button you click to submit the form. This is probably some fancy javascript, but I haven't an idea where to begin.
Any ideas how I could create two buttons, each submit the same form, but each button gives the form a different target?
THANKS!
Alternate Solution. Don't get messed up with onclick,buttons,server side and all.Just create a new form with different action like this.
Now in Javascript you can get all the elements of main form in v() with the help of getElementsByTagName(). To know whether the checkbox is checked or not
Simple and easy to understand, this will send the name of the button that has been clicked, then will branch off to do whatever you want. This can reduce the need for two targets. Less pages...!
twosubmits.php
This might help someone:
Use the formtarget attribute
It is more appropriate to approach this problem with the mentality that a form will have a default action tied to one submit button, and then an alternative action bound to a plain button. The difference here is that whichever one goes under the submit will be the one used when a user submits the form by pressing enter, while the other one will only be fired when a user explicitly clicks on the button.
Anyhow, with that in mind, this should do it:
With this javascript:
Approaches that bind code to the submit button's click event will not work on IE.
In case you are up to HTML5, you can just use the attribute
formaction
. This allows you to have a different formaction
for each button.