Javascript examples for DOM HTML Element:Input Submit
The formTarget property sets or gets the formtarget attribute of a submit button, which controls where to display the response that is received after submitting the form.
The formtarget attribute overrides the target attribute of the <form> element.
Set the formTarget property with the following Values
Value | Description |
---|---|
_blank | The response is displayed in a new window/tab |
_self | The response is displayed in the same frame (this is default) |
_parent | The response is displayed in the parent frame |
_top | The response is displayed in the full body of the window |
framename | The response is displayed in a named iframe |
A String, representing where to display the response after submitting the form
The following code shows how to check where the response will be displayed after submitting a form:
<!DOCTYPE html> <html> <body> <form action="#" method="get"> First name: <input type="text" name="fname" value="Mary"><br> Last name: <input type="text" name="lname" value="Bond"><br> <input type="submit" id="mySubmit" value="Submit" formtarget="_blank"> </form>/*from w w w .j av a 2s . co m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var v = document.getElementById("mySubmit").formTarget; document.getElementById("demo").innerHTML = v; } </script> </body> </html>