...

View Full Version : Make Image Clickable



plasterx
10-18-2005, 09:21 AM
Hi all,

How do i make an image clickable ,like a button?
I have this code:

<img src="abc.gif" onClick=" ... "> how do i use the onClick event? Say i have a button labelled alphabet 'a' and when i click on it,i want the 'a' to appear in the textbox.

my main concern is how to i get the image to be clickable?

thanks .. !

glenmac
10-18-2005, 03:33 PM
<a href = "#" onclick = "doStuff()"><img src = "yourImage.jpg"></a>
or
<img src = "yourImage.jpg" style = "cursor:hand;" onclick = "doStuff()">

fishmaster0
06-27-2014, 05:18 PM
I dont understand the "dostuff()" I want to make an image to go to a website.so what do I put in the "dostuff() I just dont understand this

Lerura
06-28-2014, 05:31 PM
to add characters to a div:
<script>
function AddChar(Char){
document.getElementById('MyTextBox').innerHTML+=Char;
}
</script>

<img src="a.gif" onclick="AddChar('a');">
<img src="b.gif" onclick="AddChar('b');">
<img src="c.gif" onclick="AddChar('c');">
.....
<div id="MyTextBox"></div>

or to show images

<script>
function ShowImage(Picture){
document.getElementById('MyPicture').src=Picture;
}
</script>


<img src="thumb_Mother.jpg" onclick="ShowImage('Mother.jpg');">
<img src="thumb_Mother.jpg" onclick="ShowImage('Father.jpg');">
<img src="thumb_House.jpg" onclick="ShowImage('House.jpg');">
.....
<img id="MyPicture" src="blank.jpg">

or as links (probably what you want)

<script>
function Goto(Location){
location.href=Location;
}
</script>


<img src="Page1.jpg" onclick="Goto('Page1.html');">
<img src="Page2.jpg" onclick="Goto('Page2.html');">
<img src="Page3.jpg" onclick="Goto('Page3.html');">
.....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum