HTML form – submit to a new window

Posted by Shek on July 8, 2008 under HTML | Be the First to Comment | Total View: 4,321 views

We use HTML form a lot for the user to input data and process those data from a PHP file, but with the standard code of a HTML form:

1
2
3
4
<form method="post" name="aform" action="afile.php">
<input type="text" name="atext" />
<input type="submit" value="submit"/>
</form>


It will direct us to the php file in the same window and the user cannot see the page of HTML form unless they press the “back” button in the browser. To have the data of the HTML form submit to a new window, it is very simple and there is no need to use javascript. All you have to do is like this, here is an example I made:

1
2
3
4
<form method="post" name="aform" action="afile.php" target="_blank">
<input type="text" name="atext" />
<input type="submit" value="submit"/>
</form>

All you need to do is to add:

target="_blank"

into the line:

<form method="post" name="aform" action="afile.php">

and form:

<form method="post" name="aform" action="afile.php" target="_blank">

With this, the data of the HTML form will submit to a new windows instead of the same one.

Not what you want? Try a Search

Add A Comment

*