Use image to submit the form instead of using button to submit the form

Use image to submit the form instead of using button to submit the form

Copy code
The code is as follows:

<form method="post" action="formtest.html" target="_blank" name="formtest">
<input type="hidden" name="userid" value="userid">
<input type="hidden" name="username" value="username">
<input type="image" src="imagesubmit.gif" border="0">
</form>

I don't want to use a button to submit the form, I want to use a better-looking image to submit

If you write it like that, it will be submitted twice, once by the input itself, and once by the js script. There are several ways to use an image as a submit button:
1.

Copy code
The code is as follows:

<form method="post" action="formtest.jsp">
<input type="hidden" name="userid" value="userid">
<input type="hidden" name="username" value="username">
<input type="image" src="imagesubmit.gif" border="0">
</form>

As the author himself wrote, this is completely possible.
2.

Copy code
The code is as follows:

<script>
function formsubmit(){
document.formtest.action="formtest.jsp";
document.formtest.submit();
}
</script>
<form method="post" name="formtest">
<input type="hidden" name="userid" value="userid">
<input type="hidden" name="username" value="username">
<img src="imagesubmit.gif" border="0" onclick="formsubmit()">
</form>

This method is often used in mixed programming, such as when the parameters you want to submit change with the dynamically retrieved content.

<<:  Vue implements small notepad function

>>:  Solution to installing vim in docker container

Recommend

Implementing shopping cart function based on vuex

This article example shares the specific code of ...

Detailed explanation of SSH password-free login configuration under Linux

Assume there are two Linux servers A and B, and w...

How to change the host name in Linux

1. View the current host name [root@fangjian ~]# ...

Vue axios interceptor commonly used repeated request cancellation

introduction The previous article introduced the ...

Using vue3 to imitate the side message prompt effect of Apple system

Table of contents Animation Preview Other UI Libr...

CSS positioning layout (position, positioning layout skills)

1. What is positioning? The position attribute in...

HTML tag overflow processing application

Use CSS to modify scroll bars 1. Overflow setting...

Install Kafka in Linux

Table of contents 1.1 Java environment as a prere...

Gojs implements ant line animation effect

Table of contents 1. Gojs Implementation 1. Drawi...

Introduction to query commands for MySQL stored procedures

As shown below: select name from mysql.proc where...

Sample code for generating QR code using js

Some time ago, the project needed to develop the ...

Dynamic starry sky background implemented with CSS3

Result:Implementation Code html <link href=...