juliemar61
New Member
I'm very new to HTML. I am trying to load an XML which contains image names and display it in a div dynamically.I can see the image names but can't assing img a source. \[code\]<!DOCTYPE html><html><head><script type="text/javascript">if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.open("GET","resimler.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML; x=xmlDoc.getElementsByTagName("pic");i=0;function displayFoto(){ad=(x.getElementsByTagName("ad")[0].childNodes[0].nodeValue);document.getElementById("showFoto").innerHTML="img/" + ad;}function next(){if (i<x.length-1){ i++; displayFoto();}}function previous(){if (i>0){ i--; displayFoto();}}</script></head><body onload="displayFoto()"><div id='showFoto'><img id='showFoto'></img></div><br> <input type="button" onclick="previous()" value="http://stackoverflow.com/questions/12729056/<<" /> <input type="button" onclick="next()" value="http://stackoverflow.com/questions/12729056/>>" /></body></html>\[/code\]Can anyone please guide me?