ALX
Well-known member
This is some HTML & Javascript for changing an image based on the users' selection in a drop-down List Box. I would like to accomplish the same thing without using Javascript. This snippet is in a View within an MVC. Is there a way this can be done through HTML exclusively or maybe replace the Javascript with some C# code ...?
VB.NET:
<img id="myImage" src="~/Content/Images/States/test.jpg" />
<select id="StateSelect" onchange="setPicture(this);">
<option value="/Content/Images/States/akPB.jpg">Arkansas</option>
<option value="/Content/Images/States/caPB.jpg">Califonia</option>
<option value="/Content/Images/States/coPB.jpg">Colorado</option>
<option value="/Content/Images/States/ctPB.jpg">Conneticuit</option>
<option value="/Content/Images/States/d.jpg">DC</option>
<option value="/Content/Images/States/flPB.jpg">Florida</option>
</select>
<script type="text/javascript">
function setPicture(select) {
selectedvalue = select.value;
document.getElementById("myImage").src = selectedvalue;
}
</script>
Last edited: