I found the following script that changes the text based on a user selection. I want to modify the code to change an image source based on the user selection.
I have been told I can do this with document.getEle mentById(image) .src = "something.jpg" > but I am not sure how to incorporate this in the code.
Thanks for any help you can provide. I am new to this.
[HTML]<html><head><ti tle>whatever</title>
<script type="text/javascript">
var textBlocks = new Array(
'Select a member',
'Member 1 text.',
'Member 2 text.');
function changetext(elem id) {
var ind = document.getEle mentById(elemid ).selectedIndex ;
document.getEle mentById("displ ay").innerHTML= textBlocks[ind];
}
</script>
</head><body>
<form>
<select id="whatever" onchange="chang etext('whatever ');">
<option value="0">Selec t</option>
<option value="1">Membe r1</option>
<option value="2">Membe r2</option>
</select><br>
</form>
<div id="display">Se lect a member</div>
</body></html>[/HTML]
I have been told I can do this with document.getEle mentById(image) .src = "something.jpg" > but I am not sure how to incorporate this in the code.
Thanks for any help you can provide. I am new to this.
[HTML]<html><head><ti tle>whatever</title>
<script type="text/javascript">
var textBlocks = new Array(
'Select a member',
'Member 1 text.',
'Member 2 text.');
function changetext(elem id) {
var ind = document.getEle mentById(elemid ).selectedIndex ;
document.getEle mentById("displ ay").innerHTML= textBlocks[ind];
}
</script>
</head><body>
<form>
<select id="whatever" onchange="chang etext('whatever ');">
<option value="0">Selec t</option>
<option value="1">Membe r1</option>
<option value="2">Membe r2</option>
</select><br>
</form>
<div id="display">Se lect a member</div>
</body></html>[/HTML]
Comment