Form submit() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form

Description

The submit() method submits the form.

The following code shows how to Submit a form:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm" action="#">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br><br>
  <input type="button" onclick="myFunction()" value="Submit form">
</form>//  ww  w . j  a  va  2s . c  o  m

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

</body>
</html>

Related Tutorials