Home Web Front-end HTML Tutorial Summary of several submission methods of html forms_HTML/Xhtml_Web page production

Summary of several submission methods of html forms_HTML/Xhtml_Web page production

May 16, 2016 pm 04:40 PM
html form Submission method

The most common, most commonly used and most common method is to use submit type. Look at the code:

Copy the code
The code is as follows:




In addition, another common method is to use pictures:

Copy code
The code is as follows:





The third way is to use a link to submit the form, using the javascript DOM model:

Copy code
The code is as follows:

This method actually calls a javascript function and uses the javascript function to submit the form. There are many and very flexible methods. For example, you can add it to the onclick event of any tag:

Copy code
The code is as follows:



Submit



But what if there are multiple submit buttons in a form?
For example, the submit buttons in a form point to different processing pages. Since the form data processing page has been determined when the form is defined, simply placing multiple submit buttons in the form cannot achieve the purpose. of. This requires javascript.
First define a function:

Copy the code
The code is as follows:

< ;script language=javascript>
function query(){
form.action=”query.php”;
form.submit();}
function update(){
form. action="update.php";
form.submit();}


Change the action attribute value of the form through javascript, so that multiple submissions can be achieved The buttons have different functions. The code on the page is as follows:

Copy the code
The code is as follows:






The above code uses an ordinary button, and the submission function is implemented by calling the javascript function in its onclick event.
With the above methods of submitting the form, I think it is almost enough to cope with the complexity. form.
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to allow multiple file uploads in HTML form How to allow multiple file uploads in HTML form Aug 28, 2023 pm 08:25 PM

In this article, we will learn how to allow multiple files uploads in HTML forms. We use multiple attributes to allow multiple file uploads in HTML forms. Several properties are available for email and file input types. Ifyouwanttoallowausertouploadthefiletoyourwebsite,youneedtouseafileuploadbox,alsoknownasafile,selectbox.Thisiscreatedusingthe&lt;in

How to get HTML form data as text and send to html2pdf? How to get HTML form data as text and send to html2pdf? Sep 06, 2023 pm 12:21 PM

html2pdf is a JavaScript package that allows developers to convert html to canvas, pdf, images, and more. It takes html as parameter and adds it to pdf or desired document. Additionally, it allows users to download the document after adding html content. Here we will access the form and add it to the pdf using the html2pdfnpm package. We will see different examples to add form data to pdf. Syntax User can follow the following syntax to pass html form data as text and send it to html2pdf. varelement=document.getElementById('form');html2

PHP file upload tutorial: How to upload files using HTML forms PHP file upload tutorial: How to upload files using HTML forms Jun 11, 2023 am 08:10 AM

PHP file upload tutorial: How to use HTML forms to upload files In the process of website development, the file upload function is a very common requirement. As a popular server scripting language, PHP can implement the file upload function very well. This article will introduce in detail how to use HTML forms to complete file uploads. 1. HTML form First, we need to use an HTML form to create a file upload page. In the HTML form, the enctype attribute needs to be set to "multipart/form-

How to process HTML forms using Java? How to process HTML forms using Java? Aug 10, 2023 pm 02:05 PM

How to handle HTML forms using Java? HTML form is one of the commonly used interactive elements in web pages, through which users can input and submit data. Java, as a powerful programming language, can be used to process and validate HTML form data. This article will introduce how to use Java to process HTML forms, with code examples. The basic steps for processing HTML form data in Java are as follows: monitor and receive POST requests from HTML forms; parse the parameters of the request; process data according to needs

PHP regular expression: how to match all form tags in HTML PHP regular expression: how to match all form tags in HTML Jun 23, 2023 am 10:38 AM

In web development, it is often necessary to use regular expressions to match strings. In HTML, the form tag is a very important tag, so if we need to get all the form tags in the page, then regular expressions become a very useful tool. This article will introduce using regular expressions in PHP to match all form tags in HTML. 1. The form tag in HTML The form tag is a very important tag in HTML. It is used to create forms. The form is used

Ajax submission methods Ajax submission methods Nov 17, 2023 pm 02:55 PM

Ajax submission methods include GET submission, POST submission, PUT submission and DELETE submission. Detailed introduction: 1. GET submission is a common submission method. It appends form data to the URL and uses Ajax to send the request. GET requests are suitable for small data amounts because they can be recorded in the browser history. cache, and can share links between multiple pages; 2. POST submission is a more common submission method, by including form data in the request body and sending it using Ajax, etc.

There are five common Ajax submission methods There are five common Ajax submission methods Jan 17, 2024 am 11:09 AM

To learn the five common submission methods in Ajax, specific code examples are required. Introduction: With the development of web applications and the increasing user demand for interactivity and real-time, Ajax technology has become an indispensable part of front-end development. Ajax (Asynchronous JavaScript and XML) is a technology that uses JavaScript for asynchronous communication. It can interact with the server's data and update the page content without refreshing the entire page. In Ajax

Explore the five different submission methods of Ajax Explore the five different submission methods of Ajax Jan 17, 2024 am 09:51 AM

In web development, Ajax is already a widely adopted technology. Simply put, Ajax initiates an asynchronous request through JavaScript and updates partial content of the page to achieve a refresh-free effect. However, Ajax request methods are not limited to GET and POST. Today, we will take an in-depth look at the five submission methods of Ajax and provide specific code examples. GET request GET request is the most common Ajax submission method. it will data

See all articles