Heres the javascript code i have.
<select id=\"image\" name=\"image\" onchange='update_img(this)' size='10'>
<div class=\"image\">
<option value=\"cod4-d.png\" id=\"image\" title=\"COD4 V1\">COD4 V1</option>
<option value=\"cod4-d2.png\" id=\"image\" title=\"COD4 V2\">COD4 V2</option>
</select></div>
<br/>
<input name=\"posted\" type=\"hidden\" id=\"posted\" value=\"yep\">
<br /><br />
<img src=\"/ladders/card/themes/blank.png\" id=\"skin_img\" name=\"skin_img\" />
<script type='text/javascript'><!-- // --><![CDATA[
var webroot = '/';
var link_base = 'ladders/card/themes/';
function update_img(obj) {
if (window.navigator.appName == 'Netscape') {
skin_img = document.getElementById('skin_img');
image_href = document.getElementById('image_href');
} else {
skin_img = document.select_skin.skin_img;
image_href = document.select_skin.image_href;
}
skin_img.src = webroot + 'ladders/card/themes/' + obj.options[obj.selectedIndex].value;
image_href.href = link_base + obj.options[obj.selectedIndex].title;
}
function hide_preview(obj) {
img = document.getElementById('preview_img');
img.src = webroot + 'ladders/card/themes';
}
// ]]></script>
It works fine in FireFox but in Internet Explorer it doesn't update the image when you select one of the options. In the select box.
This is the error is shows in Internet Explorer:
'document.select_skin.skin_img' is null or not an object
I really hope someone can help me with this. Or if someone knows another way to load the image chosen, tell me ;)
Found another way to do it ;)
For anyone who wants it here you go: It makes so you can have images in a select box and when you click on a image name it will load the image up.
It has to be apart of a FORM
<script type='text/javascript'><!-- // --><![CDATA[
function swapImage(){
var image = document.getElementById("imageToSwap");
var dropd = document.getElementById("dd");
image.src = dropd.value;
};
// ]]></script>
<select name="image" id="dd\" onChange="swapImage()" size="10">
<option id="image" value="card/themes/cod4-d.png">COD4 V1</option>
<option id="image" value="card/themes/cod4-d2.png">COD4 V2</option>
</select>
<br/><br/>
<img id="imageToSwap" src="card/themes/blank.png" />