Javascript show PNG image
I found this script online. ITs almost what I need. Take a look:
<script type="text/javascript">
imageArray = new Array("NOimglink", "imglink", "imglink", "imglink");
altArray = new Array("", "Red Star", "Yellow Star", "Pink Star");
function show() {
var Index =
document.menuForm.select1.options[document.menuForm.select1.selectedIndex].value;
var text =
document.getElementById('select1').options[document.getElementById('select1').selectedIndex].text;
document.testStar.src = imageArray[Index];
document.testStar.alt = altArray[Index];
document.getElementById("item").innerHTML =
document.getElementById("select1").value;
}
</script>
<div id="item"></div>
<form action="../action/return.html" method="post" id="menuForm"
name="menuForm">
<select id="select1" onchange="show()" name="select1">
<option value="0" selected="selected">Choose a color</option>
<option value="1">Red Star</option>
<option value="2">Yellow Star</option>
<option value="3">Pink Star</option>
</select>
<img id="testStar" height="35" alt="red star" src="" width="35"
border="0" name="testStar">
Anyways, is there any other way than using all the array lines? The
imageArray and altArray? I have over 50 select options but the array is
too much. Any easier way?
No comments:
Post a Comment