Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

button with image

Status
Not open for further replies.

justride

Programmer
Jan 9, 2004
251
US
Hi all,

is it possible to have a button with an image that when clicked doesnt try to submit the form?

Everytime I click on the button image it tries to submit the form.

Code:
<input type=\"image\" src=\"images/cut.gif\" onClick=\"document.loanlogform.DRECORDED.value=''\">

Thanks!
 
Try adding "return(false);" as another statement in your onclick. If that fails, consider using a regular button, with CSS to give it a background image, or use the "button" element with an img element between its open and closing tags.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
return false didnt work for me,

i am trying the css way but i am gettign an epty box when i use
<input type=\"button\" class=\"button\" onClick=\"document.loanlogform.DRECORDED.value=''\" >

in css...
.button{
width: 100px;
height: 55px;
padding: 55px 0 0;
margin: 0;
border: 0;
background-image: transparent url(images/cut.gif) no-repeat center top;
overflow: hidden;
cursor: pointer; /* hand-shaped cursor */
cursor: hand; /* for IE 5.x */
}

its like the html isnt pickin up on the css
 
thanks for the response, but that loaded a blank window
 
i realized I was moding the wrond css. I foudn the right one, and now the button is functional but it is not visible, i have a cursor and it works when clicked but I do not see any image, and I know the image is there, I verified with a <img> tag.

.cutbutton{
margin: 0;
border: 0;
background-image: transparent url(cut.gif) no-repeat center top;
cursor: pointer; /* hand-shaped cursor */
cursor: hand; /* for IE 5.x */
}
 
Try this instead:
Code:
<a href="javascript:void(0);" onclick="document.loanlogform.DRECORDED.value=''">
<img src=\"images/cut.gif\" alt="cut" />
</a>
or even this...
Code:
<img src=\"images/cut.gif\" alt="cut" onclick="document.loanlogform.DRECORDED.value=''" />

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top