quanpq Posted October 22, 2010 Share Posted October 22, 2010 image 1 after onclick change availablehelp soucre javascriptthank s member Link to comment Share on other sites More sharing options...
[dx] Posted October 22, 2010 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. Link to comment Share on other sites More sharing options...
thescientist Posted October 22, 2010 Share Posted October 22, 2010 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. Link to comment Share on other sites More sharing options...
thescientist Posted October 22, 2010 Share Posted October 22, 2010 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. Link to comment Share on other sites More sharing options...
quanpq Posted October 23, 2010 Author Share Posted October 23, 2010 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> Link to comment Share on other sites More sharing options...
[dx] Posted October 23, 2010 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. Link to comment Share on other sites More sharing options...
quanpq Posted October 25, 2010 Author 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> Link to comment Share on other sites More sharing options...
Synook Posted October 25, 2010 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"; Link to comment Share on other sites More sharing options...
[dx] Posted October 25, 2010 Share Posted October 25, 2010 My mistake It is like Synook says. Link to comment Share on other sites More sharing options...
quanpq Posted October 26, 2010 Author Share Posted October 26, 2010 ok thanks Haris S please your email Link to comment Share on other sites More sharing options...
Synook Posted October 26, 2010 Share Posted October 26, 2010 Why do you keep asking for user's email addresses? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.