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! Quote Link to comment 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). Quote Link to comment 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()? Quote Link to comment 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"> .. Quote Link to comment Share on other sites More sharing options...
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.