Jump to content

Work Fine With Ff & Ie8 But Not On Ie7


GoDxNero
 Share

Recommended Posts

In this code. The results boxes background are supposed to turn blue or red and alerts when all of the results are 15. This works with fire fox and ie8 but not on ie7 . Can anyone please help me decode this so that it work with ie7? Thanks alots in advance

function id(name){/* this is just a shortcut to make the actual code shorter. */return document.getElementById(name)}            function val(name){/* another shortcut function */return parseInt(id(name).value)}            function updateValues(){id('r1').innerHTML  = val('x1') + val('y2') + val('z3');id('r2').innerHTML  = val('x1') + val('y1') + val('z1');id('r3').innerHTML  = val('x2') + val('y2') + val('z2');id('r4').innerHTML  = val('x3') + val('y3') + val('z3');id('r5').innerHTML  = val('x3') + val('y2') + val('z1');id('r6').innerHTML  = val('x1') + val('x2') + val('x3');id('r7').innerHTML  = val('x1') + val('x2') + val('x3');id('r8').innerHTML  = val('y1') + val('y2') + val('y3');id('r9').innerHTML  = val('y1') + val('y2') + val('y3');id('r10').innerHTML = val('z1') + val('z2') + val('z3');id('r11').innerHTML = val('z1') + val('z2') + val('z3');id('r12').innerHTML = val('z1') + val('y2') + val('x3');id('r13').innerHTML = val('z1') + val('y1') + val('x1');id('r14').innerHTML = val('z2') + val('y2') + val('x2');id('r15').innerHTML = val('z3') + val('y3') + val('x3');id('r16').innerHTML = val('z3') + val('y2') + val('x1');checkAnswer();}function checkAnswer(){var i;var correct = 0;for(i = 1; i <= 16; ++i){var cell = "r" + i;if(parseInt(id(cell).innerHTML) == 15){id(cell).style.backgroundColor = "#00ff00";++correct;}else{id(cell).style.backgroundColor = "#FFD700";}}if(correct == 16){var used = new Array(1,2,3,4,5,6,7,8,9);for(i = 1; i <= 3; ++i){var idx = used.indexOf(val('x' + i));if(idx == -1) break;used.splice(idx, 1);idx = used.indexOf(val('y' + i));if(idx == -1) break;used.splice(idx, 1);idx = used.indexOf(val('z' + i));if(idx == -1) break;used.splice(idx, 1);}if(used.length != 0){for(i = 1; i <= 16; ++i)id("r" + i).style.backgroundColor = "#ff0000";alert("Jij hebt dezelfde cijfer meer dan 1 keer gebruikt.");}else{for(i = 1; i <= 16; ++i)id("r" + i).style.backgroundColor = "#0000ff";alert("Gefeliciteer , jij hebt het juist antwoord gevonden !");}}}

<body class="home" onload="updateValues()"><form><table id="rs1"><tr><td id="r1"></td><td id="r2"></td><td id="r3"></td><td id="r4"></td><td id="r5"></td></tr><tr><td id="r6"></td><td><select onchange="updateValues()" id="x1"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="x2"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="x3"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td id="r7"></td></tr><tr><td id="r8"></td><td><select onchange="updateValues()" id="y1"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="y2"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="y3"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td id="r9"></td></tr><tr><td id="r10"></td><td><select onchange="updateValues()" id="z1"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="z2"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="z3"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td id="r11"></td></tr><tr><td id="r12"></td><td id="r13"></td><td id="r14"></td><td id="r15"></td><td id="r16"></td></tr></table><br /><button type="reset" onclick="setTimeout('updateValues()', 10)">Reset</button></form><br />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...