Submit a Form in a New Tab

submit a form in a new tab

<form target="_blank" [....]

will submit the form in a new tab... I am not sure if is this what you are looking for, please explain better...

New tab open always even normal form form submit

you can check button values, and then submit form with you conditions,

<form method="post" name="form">
Name : <br> <input type="text" name="name"/><br />
Address : <br> <input type="text" name="address"/><br />
<input name="submit" type="submit" value="Submit" onclick="formpreview(this.form,this)">
<input type="submit" value="preview" onclick='formpreview(this.form,this)'/>
</form>

<script>
function formpreview(form,btn) {
alert(btn.value);
/*form.target='_blank';
form.action='preview.php';
form.submit();*/
if(btn.value=="preview"){
alert(btn.value);
form.target='_blank';
form.action='preview.php';
form.submit();
}
if(btn.value=="Submit"){
alert(btn.value);
form.target='_self';
form.action='proccess.php?action=submit';
form.submit();
}

}
</script>

Submit form as POST request and open new tab/window in Angular

Import the ReactiveFormsModule in your App.module.ts file

Update:

try it this way:

<form #form method="post" target="_blank" action="https://www.google.com/">
<input type="hidden" value="auth-token" />
<button mat-button color="primary" type="submit" (click)="form.submit()">Submit</button>
<input type="submit" value="Submit" />
</form>


Related Topics



Leave a reply



Submit