Dropdown menu that contains an id and calls an image to display?

Hi all,

I’m trying to create a basic dropdown effect, similar to:

<script type="text/javascript">
function getObject(id)
{
	if (document.getElementById)
	{
		return document.getElementById(id);
	}
	else if (document.all)
	{
		return document.all[id];
	}
	else if (document.layers)
	{
		return document.layers[id];
	}

	return null;
}

function swapIcon(imgid)
{
	var out = getObject('viewIcon');
	var img = getObject(imgid);
	if (img)
	{
		//change the .src
		//chnage the .alt
	}
	else
	{
		//use some default .src value
		//use sone default .alt value
	}
}
</script>

<img id="viewIcon" src="$selicon[src]" alt="$selicon[alt]" />
<form>
<select name="iconid" tabindex="1" onchange="swapIcon(this.value)">
<option id="icon_0" value="0" selected="selected">No icon</option>
<option id="icon_1" value="1">Thumbs up</option>
<option id="icon_2" value="2">Thumbs down</option>
</select>
</form>

The question is: how can I make the graphic image change the alt and src dynamically, based on the value id coming from drop down?
If you know any examples, it will be much appreciated.

As quick reference, I want to use this in vBulletin :slight_smile:

Thank you for your help.