I have a regular POST form. I have 2 submit buttons, one is called ‘Submit’ and the other is ‘Preview’.
What I want to be done is, when the submit button is clicked, I want the form to be submitted regularly in the same window. But when preview is clicked, I want the form’s action URL to be changed, and for it to be opened in a new window. E.g:
$("#myForm").attr('action', 'http://new-url.com')
.attr('target', '_BLANK');
$("#myForm").submit();
And right after the new popup window is opened, I want the old action/target attributes to be restored, so if the submit button is then clicked, it would be submitted to the regular url.
How can this be done?
1 Answer