I would like to have a submit button which contains text and an image. Is this possible?
I can get the exact look I want with code that looks like:
<button type="button">
<img src="save.gif" alt="Save icon"/>
<br/>
Save
</button>
... but I haven't found a way to have one of those for my forms. Is there a way to do that with an
<input type="submit" ...>
element? Or am I forced to go the image or text way? Thanks for your help!
Let's say your image is a 16x16 .png icon called icon.png Use the power of CSS!
CSS:
input#image-button{
background: #ccc url('icon.png') no-repeat top left;
padding-left: 16px;
height: 16px;
}
HTML:
<input type="submit" id="image-button" value="Text"></input>
This will put the image to the left of the text.
I have found a very easy solution! If you have a form and you want to have a custom submit button you can use some code like this:
<button type="submit">
<img src="login.png" onmouseover="this.src='login2.png';" onmouseout="this.src='login.png';" />
</button>
Or just direct it to a link of a page.
In case dingbats/icon fonts are an option, you can use them instead of images.
The following uses a combination of

)
for the sign in logo),In HTML:
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<form name="signin" action="#" method="POST">
<input type="text" name="text-input" placeholder=" your username" class="stylish"/><br/>
<input type="submit" value=" sign in" class="stylish"/>
</form>
In CSS:
.stylish {
font-family: georgia, FontAwesome;
}
Notice the font-family
specification: all characters/code points will use georgia
, falling back to FontAwesome
for any code points georgia
doesn't provide characters for. georgia
doesn't provide any characters in the private use range, exactly where FontAwesome
has placed its icons.
Here is an other example:
<button type="submit" name="submit" style="border: none; background-color: white">
Please refer to this link. You can have any button you want just use javascript to submit the form
You're really close to the answer yourself
<button type="submit">
<img src="save.gif" alt="Save icon"/>
<br/>
Save
</button>
Or, you can just remove the type-attribute
<button>
<img src="save.gif" alt="Save icon"/>
<br/>
Save
</button>
You can do this:
HTML code:
<form action="submit.php" method="get" id="form">
<a href="javascript: submitForm()">
<img src="save.gif" alt="Save icon"/>
<br/>
save
</a>
</form>
note: you can use and action and method of your choice and Id and any text starting from href="javascript: and ending to ()" but make sure that when I type the same things such as id and some text you type in your replacement in the same places(java script and HTML code).
java script code:
var form=document.getElementById("form");
function submitForm()
{
form.submit();
}
<input type="button" id="btnTexWrapped" style="background:
url('http://i0006.photobucket.com/albums/0006/findstuff22/Backgrounds/bokeh2backgrounds.jpg');background-size:30px;width:50px;height:3em;" />
Change input style elements as you want to get the button you need.
I hope it was helpful.
Very interesting. I have been able to get my form to work but the resulting email displays:
imageField_x: 80 imageField_y: 17
at the bottom of the email that I get.
Here's my code for the buttons.
<tr>
<td><input type="image" src="images/sendmessage.gif" / ></td>
<td colspan="2"><input type="image" src="images/printmessage.gif"onclick="window.print()"></td>
</tr>
Maybe this will help you and me as well.
:-)
Source: Stackoverflow.com