Home > Web Front-end > HTML Tutorial > Methods and options for submitting data from web pages to the background

Methods and options for submitting data from web pages to the background

WBOY
Release: 2016-09-23 11:13:15
Original
1613 people have browsed it

1. Submit via form

This is the most traditional submission method supported by HTML. You need to create a form, and then the form contains various types of form elements, and there is also a submit button. Submit to the background through the submit button. In this way, the page will be refreshed after submission.

2. Submit via web link

You can attach the parameters that need to be submitted to the link of the web page. When the user clicks the link, the browser initiates access to the link, thereby also submitting the parameters attached to the link to the background. After submission in this way, the page will also be refreshed.

3. Submit via ajax

Javascript supports the ajax method to create HTTP requests. You can create an ajax request in the event processing function of the HTML page element, carry the required submitted parameters in the url parameter, and then submit it to the background. The page will not be refreshed after submission in this way.

In actual web pages, we need to choose the appropriate submission method based on the needs of actual user interaction.

1. If you need to use some form types for user input, such as text boxes, radio buttons, and drop-down boxes, you can choose the 1st and 3rd methods. If you want the page to refresh after submission, choose the 1st method. If not, If you want the page to refresh after submission, choose option 3.

2. If you do not need form type input, you can choose the 2nd and 3rd methods. If you want the page to refresh after submission, choose the 2nd method. If you do not want the page to refresh after submission, choose the 3rd method.

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. This requires javascript.
First define a function:


Change the action attribute value of the form through javascript, so that you can implement multiple submit buttons with different functions. The code on the page is as follows:




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