Home >Web Front-end >HTML Tutorial >How to use image to submit form
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!