The submit()
method submits the form in the same way as clicking the Submit button.
submit |
Yes | Yes | Yes | Yes | Yes |
formObject.submit()
None.
No return value.
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: