I have a FORM with two submit button. What I wanted to happen is when the first button is clicked, it will submit on the tab itself. If the second button is clicked, it will proceed to a new tab.
HTML :
<form id="frm" action="" method="post" target="_blank">
<input type="text" value="data" name="data">
<input type="submit" name="first" id="first" value="Self"/>
<input type="submit" name="second" id="second" value="Tab"/>
</form>
Javascript :
$('form#frm').submit(function(){
var open_new_tab = false;
if($('#second').click){
open_new_tab = true;
}
if ( open_new_tab ) {
alert('opening to new tab');
$('form#frm').attr('target', '_blank');
}
else{
alert('opening to self_page');
$('form#frm').attr('target', '_self');
}
});
Please check this fiddle: Two Submit button in One Form
Note: I wanted to pass on some data inside the FORM into the new tab or in the tab itself.