Hi,
I am new to javascript, Please help me with the issue below.
My javascript code below should actually fetch the data from html table on button click.
function displaymessage()
{
alert ("button pressed");
var table_cells = new Array();
var table7 = document.getElementById('Auth');
for (i=0,n=table7.rows.length; i < n ; i++)
{
var Rowdata = table7.rows[i];
table_cells[i] = new Array();
for(j=0,cols = Rowdata.cells.length; j < cols; j++)
{
table_cells[i,j] = Rowdata.cells[j].innerHTML;
alert (table_cells[i,j]);
}
}
alert (table_cells[1,1]);
alert (table_cells[2,1]);
alert (table_cells[3,1]);
alert (table_cells[4,1]);
alert (table_cells[5,1]);
alert (table_cells[6,1]);
alert (table_cells[7,1]);
alert (table_cells[8,1]);
}
The problem with my code above is that the statement
"alert (table_cells[i,j]);" executes properly and shows the correct value.
But the other alert statements shows only the value of the last row of the table.
i.e., my table has 9 rows. and all the alert statements shows 9th row's 2nd column's value outside the for loop. But inside the for loop it executes fine.
I tried it in IE7.
I seem to miss something.
Could someone please help me out with this?
Thanks in advance.
I am new to javascript, Please help me with the issue below.
My javascript code below should actually fetch the data from html table on button click.
function displaymessage()
{
alert ("button pressed");
var table_cells = new Array();
var table7 = document.getElementById('Auth');
for (i=0,n=table7.rows.length; i < n ; i++)
{
var Rowdata = table7.rows[i];
table_cells[i] = new Array();
for(j=0,cols = Rowdata.cells.length; j < cols; j++)
{
table_cells[i,j] = Rowdata.cells[j].innerHTML;
alert (table_cells[i,j]);
}
}
alert (table_cells[1,1]);
alert (table_cells[2,1]);
alert (table_cells[3,1]);
alert (table_cells[4,1]);
alert (table_cells[5,1]);
alert (table_cells[6,1]);
alert (table_cells[7,1]);
alert (table_cells[8,1]);
}
The problem with my code above is that the statement
"alert (table_cells[i,j]);" executes properly and shows the correct value.
But the other alert statements shows only the value of the last row of the table.
i.e., my table has 9 rows. and all the alert statements shows 9th row's 2nd column's value outside the for loop. But inside the for loop it executes fine.
I tried it in IE7.
I seem to miss something.

Thanks in advance.
Comment