Hi Guys,
I have a small script that checks the ID of the selected option from a combo box, and writes the value of it to the src of an image with ID Img1.
This works fine - however if the selected option has an ID of "nothing" I would want an image of my choice (hard coded) to be displayed instead.
Can somebody please point me in the right direction? J/Script is new to me. If this was PHP/xHTML then it would not pose an issue!
Code:var Path='/images/options/'; function CngColor(obj){ index=obj.selectedIndex; if (index<0){ return; } document.getElementById('Img1').src=Path+obj.options[index].id; }I will stay around and help out in the PHP section aswellHTML Code:<select onchange="CngColor(this);" > <option value >Colour Options</option> <option value="nothing">DISPLAY PRE-DEFINED IMAGE</option> <option value="blue.jpg">Blue</option> <option value="red.jpg">Red</option>![]()



Reply With Quote
Bookmarks