hi
I'm having serious problems with this code. It all started when I tried to use functions. The function easy() works fine when the page loads but the button has stopped calling the check() function. could it be because I have that stored inside another function? I tried placing outside the function easy() but it still didnt work. Does anyone have any ideas? You help will be greatly appreciated
window.onload = function(){
easy();
}
function easy(){
var ids = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]
var items = [3,0,6,5,0,0,0,9,0,2,0,0,4,0,0,8,5,1,1,0,0,7,8,0,0,6,0,0,0,9,3,6,8,5,0,0,6,2,8,0,0,0,3,4,9,0,0,5,9,2,4,1,0,0,0,4,0,0,9,7,0,0,2,8,6, 3,0,0,1,0,0,5,0,7,0,0,0,3,4,0,8];
var ans = [3,8,6,5,1,2,7,9,4,2,9,7,4,3,6,8,5,1,1,5,4,7,8,9,2,6,3,4,1,9,3,6,8,5,2,7,6,2,8,1,7,5,3,4,9,7,3,5,9,2,4,1,8,6,5,4,1,8,9,7,6,3,2,8,6,3,2,4,1,9,7,5,9,7,2,6,5,3,4,1,8];
var x = 0
for (var i = 0; i < items.length; i++) {
var item = items[i];
var id = ids[i];
var element = document.getElementById(id).innerHTML = item;
if (item === 0){
document.getElementById(id).innerHTML="";
document.getElementById(id).contentEditable = "true";
document.getElementById(id).style.backgroundColor = "yellow";
function check(){
for (var i = 0; i < items.length; i++) {
var id = ids[i];
var answ = ans[i];
if(document.getElementById(id).textContent!= answ){
document.getElementById(id).style.backgroundColor = "red";
}
}
}//end of check
}
}