View Single Post
Old 01-01-2013, 02:18 PM   PM User | #3
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,461
Thanks: 52
Thanked 457 Times in 455 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
although if you are changing the image onclick, you may end up with an object of objects, and you can use the name of the sub-object to retrieve the data:

Code:
<script>
var fotos={
		dog:{title:"Fido", 
		filename:"Fido.jpg", 
		item:"3706", 
		caption: "woof!", 
		avail: "available"
		},
		cat:{title:"Whiskas", 
		filename:"Whiskas.jpg", 
		item:"9384", 
		caption: "meow!", 
		avail: "sold out"
		}
	}	
var pic1="dog";
var pic2="cat"		
alert(fotos[pic1].filename);
alert(fotos[pic2].caption);			
 </script>
That's the basics (or the easiest-to-maintain that I can see) - the finer points depend on how your page is set up and what you want to do
xelawho is offline   Reply With Quote