With IE works fine. But With Mozilla it won't work

C

C#_learner

function sortTable( ao_table, ai_sortcol, ab_header )
{
var ir, ic, is, ii, id;

ir = ao_table.rows.length;

if( ir < 1 ) return;

ic = ao_table.rows[1].cells.length;
// if we have a header row, ignore the first row
if( ab_header == true ) is=1; else is=0;

// take a copy of the data to shuffle in memory
var row_data = new Array( ir );
ii=0;
for( i=is; i < ir; i++ )
{
var col_data = new Array( ic );
for( j=0; j < ic; j++ )
{
col_data[j] = ao_table.rows.cells[j].innerText;
}
row_data[ ii++ ] = col_data;
}

// sort the data
var bswap = false;
var row1, row2;

if( ai_sortcol != lastcol )
lastseq = 'A';
else
{
if( lastseq == 'A' ) lastseq = 'D'; else lastseq = 'A';
}

// if we have a header row we have one less row to sort
if( ab_header == true ) id=ir-1; else id=ir;
for( i=0; i < id; i++ )
{
bswap = false;
for( j=0; j < id - 1; j++ )
{
// test the current value + the next and
// swap if required.
row1 = row_data[j];
row2 = row_data[j+1];
if( lastseq == "A" )
{
if( row1[ ai_sortcol ] > row2[ ai_sortcol ] )
{
row_data[j+1] = row1;
row_data[j] = row2;
bswap=true;
}
}
else
{
if( row1[ ai_sortcol ] < row2[ ai_sortcol ] )
{
row_data[j+1] = row1;
row_data[j] = row2;
bswap=true;
}
}
}
if( bswap == false ) break;
}

// load the data back into the table
ii = is;
for( i=0; i < id; i++ )
{
row1 = row_data[ i ];
for( j=0; j < ic; j++ )
{
ao_table.rows[ii].cells[j].innerText = row1[j];
}
ii++;
}
lastcol = ai_sortcol;
}


Hi i have the following code and it's working fine for IE... But with
Mozilla it doesn't work. Also it didn't gave any error message too...

Does anyone know how i can make it work for both the browsers.

thanks
C#_Learner
 
R

RobG

C#_learner said:
function sortTable( ao_table, ai_sortcol, ab_header )
{
var ir, ic, is, ii, id;

ir = ao_table.rows.length;

if( ir < 1 ) return;

ic = ao_table.rows[1].cells.length;
// if we have a header row, ignore the first row
if( ab_header == true ) is=1; else is=0;

// take a copy of the data to shuffle in memory
var row_data = new Array( ir );
ii=0;
for( i=is; i < ir; i++ )
{
var col_data = new Array( ic );
for( j=0; j < ic; j++ )
{
col_data[j] = ao_table.rows.cells[j].innerText;


innerText is an IE invention that is not widely supported - Firefox
doesn't, it uses the W3C equivalent textContent. You might find
innerHTML does the trick for a cross-browser solution. You might also
look at a function that feature detects for textContent/innerText/whatever:

<URL:http://groups.google.com/group/comp...vc=1&q=innertext+textcontent#29f5c61c0ce91bfe>


[...]
 
C

C#_learner

I tried with innerHTML as well. but it won't work though...
RobG said:
C#_learner said:
function sortTable( ao_table, ai_sortcol, ab_header )
{
var ir, ic, is, ii, id;

ir = ao_table.rows.length;

if( ir < 1 ) return;

ic = ao_table.rows[1].cells.length;
// if we have a header row, ignore the first row
if( ab_header == true ) is=1; else is=0;

// take a copy of the data to shuffle in memory
var row_data = new Array( ir );
ii=0;
for( i=is; i < ir; i++ )
{
var col_data = new Array( ic );
for( j=0; j < ic; j++ )
{
col_data[j] = ao_table.rows.cells[j].innerText;


innerText is an IE invention that is not widely supported - Firefox
doesn't, it uses the W3C equivalent textContent. You might find
innerHTML does the trick for a cross-browser solution. You might also
look at a function that feature detects for textContent/innerText/whatever:

<URL:http://groups.google.com/group/comp...vc=1&q=innertext+textcontent#29f5c61c0ce91bfe>


[...]
 
C

C#_learner

Thank you very much RobG. I worked around that and made it work ....
btw i had to change innerText to innerHTML as well. You helped me to do
it. thanks.


C#_learner said:
I tried with innerHTML as well. but it won't work though...
RobG said:
C#_learner said:
function sortTable( ao_table, ai_sortcol, ab_header )
{
var ir, ic, is, ii, id;

ir = ao_table.rows.length;

if( ir < 1 ) return;

ic = ao_table.rows[1].cells.length;
// if we have a header row, ignore the first row
if( ab_header == true ) is=1; else is=0;

// take a copy of the data to shuffle in memory
var row_data = new Array( ir );
ii=0;
for( i=is; i < ir; i++ )
{
var col_data = new Array( ic );
for( j=0; j < ic; j++ )
{
col_data[j] = ao_table.rows.cells[j].innerText;


innerText is an IE invention that is not widely supported - Firefox
doesn't, it uses the W3C equivalent textContent. You might find
innerHTML does the trick for a cross-browser solution. You might also
look at a function that feature detects for textContent/innerText/whatever:

<URL:http://groups.google.com/group/comp...vc=1&q=innertext+textcontent#29f5c61c0ce91bfe>


[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top