Hey,
I’ve finished this code, and don’t know why but IE doesn’t execute it. Could it be because IE runs JScript, not Javascript?
Basically two pictures “1” and “2” are in the <body>. Clicking on one of these runs the function pairs1() below, making two other pictures “3.jpg” and “4.jpg” appear. You should be able to click on one of “3” or “4”, and again, 2 more pictures “5” and “6” should appear. Unfortunately these last two don’t appear!
I think the problem could be that IE doesn’t recognise these lines:
[CODE]picthree.setAttribute(“onclick”,”pairs2(‘3’)”);
picfour.setAttribute(“onclick”,”pairs2(‘4’)”);
FYI pairs2() is almost identical to the code below, and creates the two images “5” and “6” – but of course pairs2() isn’t called in IE when “3” or “4” are clicked on.
Any ideas why?
[CODE]
function pairs1(pic) {
var picthree = document.createElement(“img”);
var picfour = document.createElement(“img”);
picthree.setAttribute(“src”,”3.jpg”);
picfour.setAttribute(“src”,”4.jpg”);
picthree.setAttribute(“alt”,”3″);
picfour.setAttribute(“alt”,”4″);
picthree.setAttribute(“onclick”,”question6b(‘3’)”);
picfour.setAttribute(“onclick”,”question6b(‘4’)”);
var docBody = document.getElementsByTagName(“body”)[0];
docBody.appendChild(picthree);
docBody.appendChild (picfour);
if (pic == ‘1’) {
answer = “Correct”
}
else answer = “Incorrect”
}
}