Hello,
I am trying to create a function where data in a table row if duplicated e.g. 4, then the function will display an alert indicating that the function has detected a row of data which is exactly the same
So far for any experiment I've used the function to detect only the string '4' in a row...
However for some reason the function isn't working, it doesn't detect the correct data in a row
----------
Here is the code so far
-------
----------------
I checked the javascript console and it has not displayed any errors..
Any help would be very appreciated
programmers make extra money
>>
I am trying to create a function where data in a table row if duplicated e.g. 4, then the function will display an alert indicating that the function has detected a row of data which is exactly the same
So far for any experiment I've used the function to detect only the string '4' in a row...
However for some reason the function isn't working, it doesn't detect the correct data in a row
----------
Here is the code so far
-------
Code:
<script language="javascript">
function test()
{
VV = document.getElementsByTagName('td');
for(A = 0;A < VV.length;A++)
{
VV[A].innerHTML = '45'
VV[A].setAttribute('onClick',"this.innerHTML = '4'")
}
}
function grr()
{
Y = new Array();
TY = 0;
XX = document.getElementsByTagName('td');
NN = document.getElementsByTagName('td');
for(A = 0;A < XX.length;A++)
{
Y[A] = XX[A].innerHTML;
}
alert(Y.length)
for(BB = 8 * TY;BB < Y.length;BB = BB + 8)
{
alert(TY)
//Problem Area
if('4'==Y[BB].innerHTML && '4'==Y[BB+1].innerHTML && '4'==Y[BB+2].innerHTML && '4'==Y[BB+3].innerHTML && '4'==Y[BB+4].innerHTML && '4'==Y[BB+5].innerHTML && '4'==Y[BB+6].innerHTML && '4'==Y[BB+7].innerHTML)
{
alert('a row of fours have been detected');
}
TY++
}
}
window.onload = test;
</script>
<table cellspacing=0 width=670 border=1>
<td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><tr>
<td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><tr>
<td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><tr>
<td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><tr>
</table>
<input type="button" onClick=grr()>
I checked the javascript console and it has not displayed any errors..
Any help would be very appreciated
programmers make extra money
>>