Week 1:   Starting example   •   Lession 1.1   •   Lession 1.2   •   Lession 1.3

Lession 1.2

When clicking on an image, a second image is supposed to show up somewhere else on the page.





Click on this image to see another one beside it.



Works in: FF 1.5 (Win), Opera 9 (Win), IE 6 (Win)
Does not work in:

HTML:

<img src="pict/img3.gif" width="95" height="95" border="0" onclick="otherimage()" />
<span id="image" style="margin-left:100px;"></span>

JavaScript:

var resObjekt;
if (navigator.appName.search("Microsoft") > -1){
 //resObjekt = new ActiveXObject("Microsoft.XMLHTTP");
 resObjekt = new ActiveXObject("MSXML2.XMLHTTP");
}
else {
 resObjekt = new XMLHttpRequest();
}

function otherimage(){
 resObjekt.open('get','php/kaffee_image.php',true);
 resObjekt.onreadystatechange = handleResponse;
 resObjekt.send(null);
}

function handleResponse(){
  document.getElementById("image").innerHTML = resObjekt.responseText;
}

PHP:

echo "<img src=\"pict/img10.gif\" width=\"95\" height=\"95\" border=\"0\" alt=\"\" />";