The Input Submit object represents an HTML <input> element with type="submit".
We can access an <input> element with type="submit" by using getElementById().
<!DOCTYPE html>
<html>
<body>
<input type="submit" id="mySubmit" value="Submit the form">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from ww w . j av a 2 s. com-->
var x = document.getElementById("mySubmit").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
We can create an <input> element with type="submit" by using the document.createElement() method.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w w w. j a v a2s . c om-->
var x = document.createElement("INPUT");
x.setAttribute("type", "submit");
document.body.appendChild(x);
}
</script>
</body>
</html>
The code above is rendered as follows:
Property | Description |
---|---|
autofocus | Sets or gets whether a submit button can auto focus when the page loads |
defaultValue | Sets or gets the default value of a submit button |
disabled | Endable or disable the submit button |
form | Get the form that contains the submit button |
formAction | Sets or gets the formaction attribute of a submit button |
formEnctype | Sets or gets the formenctype attribute of a submit button |
formMethod | Sets or gets the formmethod attribute of a submit button |
formNoValidate | Sets or gets whether the form data should be validated on submission |
formTarget | Sets or gets the formtarget attribute of a submit button |
name | Sets or gets the name attribute of a submit button |
type | Get the type of the submit button |
value | Sets or gets the value attribute of the submit button |
The Input Submit object supports the standard properties and events.