W
windandwaves
Hi Folk
Have a look at
http://www.corstorphine.co.nz/_quiz/quiz.php
Onload I do this:
function load_images() {
if (!check()) return;
var nav = document.getElementById('frm');
var imgs = nav.getElementsByTagName('img');
var x = 0;
for (var i =0;i<imgs.length;i++) {
imgs.number = i;
imgs.onclick = select_image;
var y = 'c' + x;
clicker = new getObj(y);
clicker.obj.onclick = function () {tick_image(x);};
x++;
}
(see http://www.corstorphine.co.nz/_quiz/j.js)
However, if I make tick_image like this:
tick_image(x) {
alert(x);
}
then I always get 12 rather than a number between 0 and 11.
Just have a look at it, please, I cant really explain it all here, but
basically I dont understand why in the following line:
clicker.obj.onclick = function () {tick_image(x);};
x always becomes 12 while it clearly should be between 0 and 12.
TIA
Have a look at
http://www.corstorphine.co.nz/_quiz/quiz.php
Onload I do this:
function load_images() {
if (!check()) return;
var nav = document.getElementById('frm');
var imgs = nav.getElementsByTagName('img');
var x = 0;
for (var i =0;i<imgs.length;i++) {
imgs.number = i;
imgs.onclick = select_image;
var y = 'c' + x;
clicker = new getObj(y);
clicker.obj.onclick = function () {tick_image(x);};
x++;
}
(see http://www.corstorphine.co.nz/_quiz/j.js)
However, if I make tick_image like this:
tick_image(x) {
alert(x);
}
then I always get 12 rather than a number between 0 and 11.
Just have a look at it, please, I cant really explain it all here, but
basically I dont understand why in the following line:
clicker.obj.onclick = function () {tick_image(x);};
x always becomes 12 while it clearly should be between 0 and 12.
TIA