php_novice2007 Posted August 14, 2007 Share Posted August 14, 2007 Hi, I've got 2 javascript variables, var myColour = "blue"; and var blue = "./images/blue.jpg"; And I want to create an image thumbnail <img src=" + ??? + "width=10 height=10> where in ??? I want "./images/blue.jpg" But I only know the value of myColour (Its actually a value extracted from a text file). (it might not be blue, might be red, green, etc... and I have var red = "./images/red.jpg" etc..) How do I do the conversion..? Thanks! Link to comment https://forums.phpfreaks.com/topic/64809-converting-things/ Share on other sites More sharing options...
NArc0t1c Posted August 14, 2007 Share Posted August 14, 2007 function create(location){ var image = document.getElementById('img'); image.src = location; } And the image: <img src="" id="img" alt="Loading.." /> I haven't done this in ages but should work(sorry if it doesn't). Link to comment https://forums.phpfreaks.com/topic/64809-converting-things/#findComment-323293 Share on other sites More sharing options...
php_novice2007 Posted August 14, 2007 Author Share Posted August 14, 2007 so where would I call create()? Link to comment https://forums.phpfreaks.com/topic/64809-converting-things/#findComment-323346 Share on other sites More sharing options...
NArc0t1c Posted August 14, 2007 Share Posted August 14, 2007 <input type="button" onclick="create('image.gif')" value="Change Image"> .. Link to comment https://forums.phpfreaks.com/topic/64809-converting-things/#findComment-323562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.