PDA

View Full Version : How do I do a button with an image ?



jeddi
Jan 21st, 2009, 01:11 PM
Hi,

Instead of a button I want a clickable image,
but I am not sure how to do it :o

This is my button code:


<input type='button' value='U' name='btnUnderline' onclick="wrapText(document.getElementById('TheTextArea'),'<u>','</u>');">


and this is the image that I want to use:


<img src="picts/under.gif" width="21" height="20" alt="Under" />

So instead of the "U" inside a button, I'll have the image that I want to use.

Can anyone help me on this ?

Common
Jan 21st, 2009, 01:41 PM
Me again. :)


<input type="image" src="picts/under.gif" name="btnUnderline" onclick="wrapText(document.getElementById('TheTextArea'),'<u>','</u>');">

But you know since youre just using this to onClick input data into your textarea, you can just put an onClick in an img tag.

Tres facile!

jeddi
Jan 21st, 2009, 03:34 PM
Ah ha .

Yep thanks - I will just add the onClick to the img tag
much better :)

jeddi
Jan 21st, 2009, 10:53 PM
For some eason this onClick on my image tag isn't working :confused:

This is what I have in my code:


<img class="imgbtn"
src="picts/italic.gif"
width="21"
height="20"
alt="Italic" onClick="wrapText(document.getElementById('TheTextArea'),'[i]','[/i>');">

Have I messed something up ?

My images show up but the alt value doesn't show
on hover and they don't click :(

Any ideas ?

jeddi
Jan 21st, 2009, 11:08 PM
OK,
I fixed the onclick - (the script was in the wrong file :o )

But why arn't the alt tags showing ?

jerry62704
Jan 22nd, 2009, 09:28 PM
Did you expect the alt property to show a tooltip? It doesn't except in IE where it does by mistake. You want the title property if you want a tooltip that shows in all browsers.

You still need the alt, of course. It's purpose is to show the information that an image would show in cases where someone can't see the image.