Home > Web Front-end > JS Tutorial > body text

How does Javascript implement the submit function?

醉折花枝作酒筹
Release: 2023-01-06 11:17:01
Original
10405 people have browsed it

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>
Copy after login

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

Syntax

formObject.submit()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template