
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Submit formTarget property
The HTML DOM Input Submit formTarget property is used for setting or returning the formTarget attribute value of a submit button. The HTML DOM Input Submit formTarget property is where the response from server should be displayed after the form data being submitted. The formTarget property overrides the target property of the form element. It introduced in HTML5 for input element with type submit.
Syntax
Following is the syntax for −
Setting the formTarget property −
submitObject.formTarget = "_blank|_self|_parent|_top|framename"
Here, _blank will open the response in new window;_self will open the response in the same window; parent will open in the parent frame ; _top will open in full window body and framename will open it in a specified named frame.
Example
Let us look at an example for the Submit formTarget property −
<!DOCTYPE html> <html> <body> <h1>Submit formTarget property</h1> <form id="FORM_1" action="/Sample.php" style="border:solid 2px green;padding:2px"> UserName: <input type="text" id="USR"> <br> Location: <input type="text" id="Loc"> <br><br> <input type="submit" id="SUBMIT1" formtarget=_self> </form> <p>View the form response in the new window instead of same window by clicking the below button</p> <button onclick="changeTarget()">CHANGE</button> <p id="Sample"></p> <script> function changeTarget() { document.getElementById("SUBMIT1").formTarget="_blank"; document.getElementById("Sample").innerHTML = "The response will now open in the new window"; } </script> </body> </html>
Output
This will produce the following output −
On clicking the CHANGE button −
- Related Articles
- HTML DOM Input Submit autofocus property
- HTML DOM Input Submit disabled property
- HTML DOM Input Submit form property
- HTML DOM Input Submit formAction property
- HTML DOM Input Submit formEnctype property
- HTML DOM Input Submit formMethod property
- HTML DOM Input Submit formNoValidate property
- HTML DOM Input Submit name property
- HTML DOM Input Submit object property
- HTML DOM Input Submit type Property
- HTML DOM Input Submit value Property
- HTML DOM Input Time type Property
- HTML DOM Input Time value Property
- HTML DOM Input URL autocomplete Property
- HTML DOM Input URL autofocus Property
