Click to See Complete Forum and Search --> : Changing picture using onclick
Bourbon
05-10-2006, 10:42 PM
I have a picture of a garage door in a table. I also have a color scheme below. I need to know how to change the main picture when the user clicks on the color of the garage door they want to see.
Thanks in advance
Darryl
Please see attachment below.
phpnovice
05-10-2006, 11:10 PM
<img name="myimage" ...etc...>
Given the above, the following JavaScript will change the picture:
document.images["myimage"].src = "...url...";
Bourbon
05-11-2006, 12:30 AM
Not what I am looking for, have a look at the attached image link.
sridhar_423
05-11-2006, 12:52 AM
if this is what you're asking..
<script language=javascript>
colorImgArray=new Array();
colorImgArray[0]="one.jpg";
colorImgArray[1]="two.jpg";
colorImgArray[2]="three.jpg";
colorImgArray[3]="four.jpg";
</script>
<td bgcolor=red onclick="document.images[0].src=colorImgArray[0]"> </td>
<td bgcolor=red onclick="document.images[0].src=colorImgArray[1]"> </td>
<td bgcolor=red onclick="document.images[0].src=colorImgArray[2]"> </td>
<td bgcolor=red onclick="document.images[0].src=colorImgArray[3]"> </td>
--------------
instead of defining onclick these many times, set these events on td's using onload.
Nedals
05-11-2006, 01:59 AM
I think you are asking for a script that will change only the COLOR of the door when clicking the pallette. I pretty sure you cannot do that. What you need to do is create your picture using two images; one for the garage and an overlay for the door. Then create multiple images of the door for each color.
You can then use a simplifed version of sridhar_423 script. (think... parsing variables to a function).
phpnovice
05-11-2006, 08:01 AM
Not what I am looking for, have a look at the attached image link.
Yes, the code posted is what you're looking for -- because it is basically all that JavaScript can do for you. As for whether the exact code is what you're looking for, or not, is not the question. It is the technique demonstrated which I was pointing out -- not the exact coding.
Note that this site is not a place for obtaining free contract-programming services. Everyone that answers questions here are just visitors to this site as you are. Thus, it is not up to us visitors to supply you with a complete and custom solution -- only to help you arrive at your own custom solution. So, why don't you do a bit more than just post a picture and ask for a solution?
Thanks.
sridhar_423
05-11-2006, 11:09 PM
hey Nedals, can't the color of door be changed if a map is defined on the image and inserting a div in it which contains an image element. By clicking on color, the image in the div gets set. i've never worked on maps before. so, donno whether its feasible or not.
Nedals
05-12-2006, 01:28 AM
...which contains an image element. By clicking on color, the image in the div gets set.That's kind of what I am suggesting only you don't need the map. Just put one image, contained in a div, on top of the other.