Reputation: 396
I have come across similar questions on here but none that directly refer to the one i am looking for. So i have a form div with target="_blank". When clicking an Input submit link i would like the form to open in a new tab.
I have some javascript code in the background that manipulates the form item based on buttons to give different options. When the submit button is clicked i would like the form values to be correctly passed with the form and to open in a new tab.
If i disable Javascript the form correctly opens in a new tab, so the Javascript is blocking the new tab. How can i get my form to open correctly whilst passing the option values with the form?
Some example code:
<form id="search" name="search" action="www.search.com" target="_blank" method="post">
...
<input type="submit" name="commit" value="Search" class="button">
Also why would Javascript be blocking the new tab popup?
Upvotes: 1
Views: 5564
Reputation: 29
try this for Open form in new tab on submit click
<input type="submit" target="_blank" name="commit" value="Search" class="button">
Upvotes: 2
Reputation: 328
¿Have you tried calling your JavaScript function like this?
<form id="search" name="search" action="www.search.com" target="_blank" method="post" onSubmit="return function();">
Edit: After this call, you can do your field settings on JS and if everything is alright, just return true for the form to be submitted, or false to cancel submission.
Upvotes: 0