previous

page 33

next
my cell_clicked.js
function cell_clicked(image) {
var cn=image.getAttribute('cn');
if (cn==0) {
image.src='counters/' + pick + '.png';
image.setAttribute('cn',pick);
var id=image.id;
var row=parseInt(id/5);
var arr=get_cns(row);
var score=worth(arr);
var element=document.getElementById('s' + row);
var old_score=element.textContent;
element.textContent=score;
total=total - old_score + score;
var col=id % 5;
var arr=get_col_cns(col);
var score=worth(arr);
var element=document.getElementById('s' + (col + 5));
var old_score=element.textContent;
element.textContent=score;
total=total - old_score + score;
var element=document.getElementById('total');
element.textContent=total;
pick=Random(9);
show_pick();
}
}
a picked counter remains at the end

We'll need a variable n at the start, set to zero.
It will be incremented by one for each click.
show_pick will set the picked counter image to empty when n reaches 25.

This you should try by yourself.

previous
next