I am new to jquery and php, so I apologize if the question is to simple.
I have to change the image displayed depending on the option selected in the list box.
So far my jquery is able to retrieve and display the desired img id.I intially tried to post the image id back to the php script and then retrieve the image, but later realised I can directly manipulate the img tag(since my images are name 1.jpg,2.jpg).Can someone please help me? Thank you!
Here s the relevant code:
HTML:
<img id="design" class ="img-rounded" alt="Ad Picture" width="450p" height="450"/>
<input type="button" id="GetImage" class="btn" value="Get Image">
Jquery:
$('#GetImage').live("click",function() {
var imageid= $('#UserIds').val();
$.ajax({
type:'POST',
url:'ProvidingFeedback.php',
data:{id:imageid},
success: function(msg){
if(result=='success') {
$('#design').attr('src','/img/2.jpg');
}
}
});
});
I
because you are selecting image as id try only img or #design
should be
and
should be