WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > WEB DESIGN > Graphics & Multimedia > remote image change

Reply
  Thread Tools Display Modes
Old 21st June 10, 09:08 PM   #1
cway
WLC Member
 
Join Date: Jul 2008
Location: USA
Posts: 22
Default remote image change

Does anybody know how to do this:
click on a color swatch and a remote image changes.
like the car websites do.



I don't know if this can be done with only css or if there needs to be javascript, too.

Thanks!
Cway
cway is offline   Reply With Quote
Old 22nd June 10, 02:55 AM   #2
meesa
WLC Mod
 
meesa's Avatar
 
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,134
Default Re: remote image change

Flash would be the easiest way, but Javascript if you can't do Flash.
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum.
meesa is offline   Reply With Quote
Old 22nd June 10, 03:20 PM   #3
cway
WLC Member
 
Join Date: Jul 2008
Location: USA
Posts: 22
Default Re: remote image change

Thanks for the quick reply, meesa!
Do you know of a good flash or javascript?
cway is offline   Reply With Quote
Old 22nd June 10, 03:33 PM   #4
meesa
WLC Mod
 
meesa's Avatar
 
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,134
Default Re: remote image change

Here is a simple JS code.

Code:
<script type="text/javascript">
var pics=new Array(
"pic1-URL.jpeg",
"pic2-URL.jpeg");

function cngImg(num){
document.getElementById('slideshow').src=pic[num];
}
</script>
With that, you simply add all your image URLs tothe array pics, just like pic1-URL.jpeg, they must have the double quoates, and each one should be separated by a comma, like above.

HTML Code:
<div>
<img src="originalImg.jpeg" id="slideshow" alt="" />

<img src="redButton.jpeg" alt="" onclick="cngImg(0)" />
<img src="blueButton.jpeg" alt="" onclick="cngImg(1)" />
</div>
Note that I used 0 as the first one and 1 as the second, that is because they start at 0. If you want to chanage to the first image, it's 0, second is 1, and so on, just change that number in the ().

Also make sure that you don't tell it to go to an image that doesn't exist, your highest number should be how many URLs you have minus 1 (because it starts at 0)
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum.
meesa is offline   Reply With Quote
Old 20th July 11, 08:09 PM   #5
entranced
WLC Member
 
Join Date: Jul 2011
Posts: 5
Default Re: remote image change

This is how I would go about it. This seems to be the easiest way. Basically you will be displaying a different image with each selection. I am not sure if there is a way to actually change the color on the same image, which I imagine is the approach that you may have been going for. I would just use different images.
entranced is offline   Reply With Quote
Reply


Thread Tools
Display Modes
Linear Mode Linear Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:16 AM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyright© 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.