html - Changing the img src through javascript whilst src is stored in an array -


i'm trying change source of image on page load yet instead of image loading, string of it's location being displayed. simple solution cannot see it.

<form id="form1"><h1 id="dude">question?</h1><br>                     <h2>                         <label ="answer1" id="label1"><img src="imgs//img.png" id="img1" width="150" height = "150"></label>                         <input type="radio" name="answer" id="answer1">                     </h2><br>                     <h2>                         <label ="answer2" id="label2"><img src="imgs//img.png" id="img2" width="150" height = "150"></label>                         <input type="radio" name="answer" id="answer2">                     </h2><br>                     <h2>                         <label for="answer3" id="label3"><img src="imgs//img.png" id="img3" width="150" height = "150"></label>                         <input type="radio" name="answer" id="answer3">                     </h2>                     <h2>                         <label for="answer4" id="label4"><img src="imgs//img.png" id="img4" width="150" height = "150"></label>                         <input type="radio" name"answer" id="answer4">                     </h2>                 </form> 

and javascript

//  populate mulchoiimg array    mulchoiimg[1] = new array('which picture most', 'imgs//img2.png','imgs//img2.png','imgs//img2.png','imgs//img2.png'); function popmulc(){                 document.getelementbyid("dude").innerhtml= mulchoi[currentquestion][0];                 document.getelementbyid("label1").innerhtml=mulchoi[currentquestion][1];                 document.getelementbyid("label2").innerhtml=mulchoi[currentquestion][2];                 document.getelementbyid("label3").innerhtml=mulchoi[currentquestion][3];                 document.getelementbyid("label4").innerhtml=mulchoi[currentquestion][3];}//close func 

any ideas appreciated.

you aren't changing image src, rather innerhtml of label element.

you need image element label , image.src = mulchoi[currentquestion][1];


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -