quanpq 0 Posted October 22, 2010 Report Share Posted October 22, 2010 image 1 after onclick change availablehelp soucre javascriptthank s member Quote Link to post Share on other sites
[dx] 4 Posted October 22, 2010 Report Share Posted October 22, 2010 function change_color(color) { document.getElementById("t_shirt").src = "/images/"+color+"/.jpg";} Then find elements in html for these to boxes, white and gray and put function onclick=java script: change_color('white'); and same for gray.Also. You can change location of files in js code above, or put your images to /images/ folder with names white.jpg and gray.jpgThen you must name div or some element with id=t_shirt, or change it in function. Quote Link to post Share on other sites
thescientist 231 Posted October 22, 2010 Report Share Posted October 22, 2010 (edited) what do you have so far? it might take a combination of PHP and Javascript. PHP could write the script for each page so that when a given color sqaure for an item is clicked, the script will already know the right image to swap it with. Really depends on your setup and what code you have so far. Edited October 22, 2010 by thescientist Quote Link to post Share on other sites
thescientist 231 Posted October 22, 2010 Report Share Posted October 22, 2010 (edited) there's no need to double post, and surely you can wait longer than a half hour for a response. You should just stick with one forum and go with it. I'm sure a mod will merge this shortly. Edited October 22, 2010 by boen_robot Topics merged... Quote Link to post Share on other sites
quanpq 0 Posted October 23, 2010 Author Report Share Posted October 23, 2010 (edited) thanks Haris S helphave folder images 2 filelaptop_white.jpglaptop_black.jpgafter onclickcode html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><script>function change_color(color) { document.getElementById("t_shirt").src = "/images/"+color+"/.jpg";}</script></head><body><img src="images/laptop_white.jpg" id="t_shirt" /><a href="#" onclick="java script:change_color('laptop_black')">color black</a></body></html> Edited October 23, 2010 by quanpq Quote Link to post Share on other sites
[dx] 4 Posted October 23, 2010 Report Share Posted October 23, 2010 Try this linedocument.getElementById("t_shirt").src = "/images/"+color+"/.jpg";todocument.getElementById("t_shirt").src = "images/"+color+"/.jpg";Maybe, location isn't good. Quote Link to post Share on other sites
quanpq 0 Posted October 25, 2010 Author Report Share Posted October 25, 2010 help no run file<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><script>function change_color(color) { document.getElementById("t_shirt").src = "images/"+color+"/.jpg";}</script></head><body><img src="images/laptop_white.jpg" id="t_shirt" /><a href="#" onclick="java script:change_color('charger')">color black</a></body></html> Quote Link to post Share on other sites
Synook 47 Posted October 25, 2010 Report Share Posted October 25, 2010 Are your images really called ".jpg"? Are you sure you don't mean: document.getElementById("t_shirt").src = "images/"+color+".jpg"; Quote Link to post Share on other sites
[dx] 4 Posted October 25, 2010 Report Share Posted October 25, 2010 My mistake It is like Synook says. Quote Link to post Share on other sites
quanpq 0 Posted October 26, 2010 Author Report Share Posted October 26, 2010 (edited) ok thanks Haris S please your email Edited October 26, 2010 by quanpq Quote Link to post Share on other sites
Synook 47 Posted October 26, 2010 Report Share Posted October 26, 2010 Why do you keep asking for user's email addresses? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.