submit a form in a new tab

PhpJqueryFormsHttp Post

Php Problem Overview


I'd like (just to test some functions, after I'll avoid this behaviour) to load the page called by submit on a new tab : is it possible?

Php Solutions


Solution 1 - Php

<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...

Solution 2 - Php

It is also possible to use the new button attribute called formtarget that was introduced with HTML5.

<form>
  <input type="submit" formtarget="_blank"/>
</form>

Solution 3 - Php

I have a [submit] and a [preview] button, I want the preview to show the print view of the submitted form data, without persisting it to database. Therefore I want [preview] to open in a new tab, and submit to submit the data in the same window/tab.

<button type="submit" id="liquidacion_save"          name="liquidacion[save]"          onclick="$('form').attr('target', '');"      >Save</button></div>    <div>
<button type="submit" id="liquidacion_Previsualizar" name="liquidacion[Previsualizar]" onclick="$('form').attr('target', '_blank');">Preview</button></div>  

Solution 4 - Php

Add target="_blank" to the <form> tag.

Solution 5 - Php

Since you've got this tagged jQuery, I'll assume you want something to stick in your success function?

success: function(data){
    window.open('http://www.mysite.com/', '_blank');
}

Solution 6 - Php

Try using jQuery

<script type="text/javascript">
$("form").submit(function() {
$("form").attr('target', '_blank');
return true;
});
</script>

Here is a full answer - http://ftutorials.com/open-html-form-in-new-tab/

Solution 7 - Php

Your browser options must be set to open new windows in a new tab, otherwise a new browser window is opened.

Solution 8 - Php

This will also work great, u can do something else while a new tab handler the submit .

<form target="_blank">
    <a href="#">Submit</a>
</form>

<script>
    $('a').click(function () {
        // do something you want ...

        $('form').submit();
    });
</script>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmarkzzzView Question on Stackoverflow
Solution 1 - PhpStraeView Answer on Stackoverflow
Solution 2 - PhpdragontreeView Answer on Stackoverflow
Solution 3 - PhpjuanmfView Answer on Stackoverflow
Solution 4 - PhpThiefMasterView Answer on Stackoverflow
Solution 5 - PhpSickHippieView Answer on Stackoverflow
Solution 6 - PhpwebtechView Answer on Stackoverflow
Solution 7 - PhpArtieJView Answer on Stackoverflow
Solution 8 - PhpLinkView Answer on Stackoverflow