biggieuk Posted December 10, 2008 Share Posted December 10, 2008 Hi, Im having a little problem with my dropdown. It is populated dynamically from images inside a folder. I have a 'preview button' next to the dropdown which i would like (when clicked) to popup a window displaying the image in the dropdown. I tried making the preview button have code along the lines of: <img src="../images/uploaded/+document.getElementById.[imgdropdown].value" /> however this didnt work. Thanks for any help with this! Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 11, 2008 Share Posted December 11, 2008 And where's your code? Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 11, 2008 Share Posted December 11, 2008 Here's a very simple example. It requires that you have the images (one.jpg, two.jpg & three.jpg) on the local computer inthe folder "C:\img\". However, the same logic would work for images on a web server. <html> <head> <script> function showImg(selID) { selObj = document.getElementById(selID); selValue = selObj[selObj.selectedIndex].value; window.open('c:\\img\\' + selValue + '.jpg'); } </script> </head> <body> <select name="img" id="img"> <option value="one">One</option> <option value="two">Two</option> <option value="three">Three</option> </select> <button onclick="showImg('img');">Show Image</button> </body> </html> Quote Link to comment Share on other sites More sharing options...
biggieuk Posted December 11, 2008 Author Share Posted December 11, 2008 Thanks mjdamato, i tweaked this slightly and managed to get this working perfectly! 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.