
previous

page 7
next
<script>
function one_row() {
var s1=" <img src='counters/0.png' class='cell' id='";
var s2="' cn='0' onClick='cell_clicked(this);'>";
for (var i=0; i<5; i++) {
document.write(s1 + i + s2);
}
document.write('<div>0</div>');
}
</script>
function one_row() {
var s1=" <img src='counters/0.png' class='cell' id='";
var s2="' cn='0' onClick='cell_clicked(this);'>";
for (var i=0; i<5; i++) {
document.write(s1 + i + s2);
}
document.write('<div>0</div>');
}
</script>
You probably didn't think to put it in a function but remember that we have to do 4 more rows!
So how do we use this function?
Before we go there, let me show you a better way of storing JavaScript functions.
Rather than cluttering up our index.html file, we store them in separate files.
So create a file called one_row.js and store the above code in it but without the script tags.
To make this function available to our html, we add this line before we use the function.
<script src='one_row.js'></script>
Then the body of our html can be simply:
<div class='row'>
<script>one_row();</script>
</div>
<script>one_row();</script>
</div>
previous
next