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
{
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