overwriting in javascript
<pre><code>&lt;div id='tbl'&gt; &lt;/div&gt;

&lt;script lang="Javascript"&gt;
var gd = new Array(16);
var a=0;
for(a=0; a&lt;16; a++)
    gd[a] = new Array(16);
var sd = new Array(16);
for(a=0; a&lt;16; a++)
    sd[a] = new Array(16);

var b1=0, b2=0;
for(b1=0; b1&lt;16; b1++)
{
    for(b2=0; b2&lt;16; b2++)
    {
        gd[b1][b2]="A";
        sd[b1][b2]="A";
    }
}

var c1=0, c2=0;
var score=0;

ble = "&lt;center&gt;&lt;table&gt;";
for(c1=0; c1&lt;16; c1++)
{
    ble += "&lt;tr&gt;";
    for(c2=0; c2&lt;16; c2++)
    {
        ble += "&lt;td onClick='changeColor(this)'&gt;" + gd[c1][c2] + "&lt;/td&gt;";
    }
    ble += "&lt;/tr&gt;";
}
ble += "&lt;/table&gt;&lt;/center&gt;";

document.getElementById('tbl').innerHTML = ble;

function changeColor(tdd)
{
    if(tdd.bgColor=='white')
    {
        tdd.bgColor='red'; 

        alert(c1);
        /*if (gd[c1][c2] == sd[c1][c2])
            score+=5;
        else
            score-=2;*/
    }
    else
    {
        tdd.bgColor='white'; 
    }
}
function scc()
{
    document.getElementById('scf').innerHTML = score;
}
&lt;/script&gt;
&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;button type='button' onclick='scc()'&gt; Click to see current score&lt;/button&gt; &lt;div id="scf"&gt;0&lt;/div&gt; &lt;/center&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p>In the code given above, is there any way to get <code>c1</code> and <code>c2</code> current values in changeColor function instead of =16.</p>

<p>Otherwise, is there a way to write into the document so that it won't be overwritten every time?</p>
