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

WBOY
Release: 2016-05-16 16:40:18
Original
2608 people have browsed it

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.
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!