Home  >  Article  >  Web Front-end  >  How does Javascript implement the submit function?

How does Javascript implement the submit function?

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-06-09 14:52:5910188browse

In js, you can use the submit method to implement the form submit function. The syntax format is "form object.submit()". This method submits the form data to the web server. The way to submit the form is the same as the user clicking the Submit button. The same, but the form's onsubmit event handler will not be called.

How does Javascript implement the submit function?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

<html>
  <head>
    <script language="javascript" type="text/javascript">
      function FormSubmit() {
        myFrm.action = "a.asp";
        myFrm.submit();
      }
    </script>
  </head>
  <body>
    <form name="myFrm">
      表单项1:<input type="text" name="tt1" />

      表单项2:<input type="text" name="tt2" />
    </form>

    <img
      alt="提交"
      src="b.gif"
      width="50"
      height="22"
      style="cursor: hand"
      onclick="FormSubmit();"
    />
  </body>
</html>

submit() method submits form data to the web server.

Syntax

formObject.submit()

Description

This method submits the form in the same way as if the user clicks the Submit button, but the form's onsubmit event handler will not be called.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How does Javascript implement the submit function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn