Hi,
Below is a working model that changes the image with a dropdown menu.
How would I change the image without the url being the value? Id like to have the value="yellow" and maybe id="image3.jpg" . How would that work?
Thanks in advance.
Below is a working model that changes the image with a dropdown menu.
How would I change the image without the url being the value? Id like to have the value="yellow" and maybe id="image3.jpg" . How would that work?
Thanks in advance.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>JQuery Image</title>
<script type="text/javascript" src="/script/jquery-1.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#image").change(function() {
$("#imagePreview").empty();
if ( $("#image").val()!="" ){
$("#imagePreview").append("<img src=\"" + $("#image").val() + "\" />");
}
else{
$("#imagePreview").append("displays image here");
}
});
});
</script>
</head>
<body>
<select name="image" id="image" class="inputbox" size="1">
<option value=""> - Select Image - </option>
<option value="image1.jpg">Blue</option>
<option value="image2.jpg">Red</option>
<option value="image3.jpg" selected>Yellow</option>
</select>
<div id="imagePreview">
displays image here
</div>
</body>
</html>
Comment