Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use an image as a submit button?

Can someone help to change this to incorporate an image called BUTTON1.JPG instead of the standard submit button?

<form id='formName' name='formName' onsubmit='redirect();return false;'>     <div class="style7">         <input type='text' id='userInput' name='userInput' value=''>         <input type='submit' name='submit' value='Submit'>     </div> </form>  
like image 391
Rolf Avatar asked Jan 07 '13 16:01

Rolf


People also ask

Can you use an image as a submit button?

Definition and UsageThe <input type="image"> defines an image as a submit button. The path to the image is specified in the src attribute.

How do I make an image a button?

Placing the <img> tag inside the <button> tag creates a clickable HTML button with an image embedded in it.

How do I put an image on a button in HTML?

The image buttons in the HTML document can be created by using the type attribute of an <input> element. Image buttons also perform the same function as submit buttons, but the only difference between them is that you can keep the image of your choice as a button.


2 Answers

Use an image type input:

<input type="image" src="/Button1.jpg" border="0" alt="Submit" /> 

The full HTML:

<form id='formName' name='formName' onsubmit='redirect();return false;'>    <div class="style7">      <input type='text' id='userInput' name='userInput' value=''>      <input type="image" name="submit" src="https://jekyllcodex.org/uploads/grumpycat.jpg" border="0" alt="Submit" style="width: 50px;" />    </div>  </form> 
like image 139
Devin Burke Avatar answered Oct 28 '22 17:10

Devin Burke


Why not:

<button type="submit">   <img src="mybutton.jpg" /> </button> 
like image 45
volume one Avatar answered Oct 28 '22 17:10

volume one