Home  >  Article  >  Web Front-end  >  How to use image to submit form

How to use image to submit form

php中世界最好的语言
php中世界最好的语言Original
2018-02-10 09:48:412305browse

This time I will show you how to use image to submit form, what are the precautions to use image to submit form, the following is a practical case, let's take a look.

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 nicer image to submit it

That way it will be submitted twice, the input itself is submitted once, and the js script is submitted again Submit once
Use
picture as the submit button. There are several methods as follows: 1.

<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>

Just as the original poster wrote, this is completely Yes

2.

<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 hybrid

ProgrammingIf the parameters you want to submit change with the dynamically retrieved content

I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

How to implement HTML-like command line interface

How to implement list loop with html+css+javascript Scroll

How to use button trigger to achieve background color flash

The above is the detailed content of How to use image to submit form. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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