Analysis on the problems of Picture Button submission and form repeated submission in web Development
This article mainly introduces the problem analysis of picture button submission and form repeated submission in web development, which is very detailed and has certain reference value. Interested friends must finish reading it!
In many cases, in order to beautify the form, the submit button will be changed to a picture instead. But if you don't pay attention to the details, it can lead to repeated submission of the form, leading to some inexplicable errors, such as repeatedly inserting database records.
Let's look at the following simple form code:
The code is as follows:
This code is correct and there will be no problem of repeated submission. "" In fact, the effect is the same as "". A little bit of that picture will perform the submit () operation.
But some people are worried and add an onclick action to image, such as:
The code is as follows:
Now click the picture button and submit it twice, resulting in repeated submissions. Its function is equivalent to:
The code is as follows:
How does a button like this prohibit repeated submissions?
Solution:
The code is as follows:
There are two ways to submit a form using a picture:
1.
This picture will automatically submit the Form form, that is, type= "submit" if you want to judge and verify it before submitting it.
The code is as follows:
It is normal to submit in this way, and the effect is the same as above. Therefore, please avoid submitting data in the first way, especially in the application of struts
Note: css: cursor:hand can only be recognized by IE, not Firefox. And pointer is compatible!
Note! Either way, the submission is included in between, otherwise, the submission is invalid
These are all the contents of this article entitled "problem Analysis of Picture Button submission and form repeat submission in web Development". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!