Javascript Reference - HTML DOM Form submit() Method








The submit() method submits the form in the same way as clicking the Submit button.

Browser Support

submit Yes Yes Yes Yes Yes

Syntax

formObject.submit()

Parameters

None.

Return Value

No return value.





Example

The following code shows how to submit a form.


<!DOCTYPE html>
<html>
<body>
<form id="myForm" action="url">
  First name: <input type="text" name="fname"><br>
  <input type="button" onclick="myFunction()" value="Submit form">
</form><!--   w  ww  .  j  a v a 2s.c  o  m-->

<script>
function myFunction() {
    document.getElementById("myForm").submit();
}
</script>

</body>
</html>

The code above is rendered as follows: