F
foldface
Hi
Sorry but to view the code below you'll have to copy it into a temp.html file,
haven't access to a online web page anymore.
The code switches the rows and columns of a table. Its been tried in the
versions below. Note that it works in the latest version of IE before SP2,
whats changed?
By not working I mean that it'll switch the columns/rows twice then lose
some of the information? Can fix it by substituting the commented out lines
for the ones above.
mozilla 1.7.2, works
firefox 0.9.3, works
IE6.0.2800, works
IE6.0.2900, doesn't work
Any ideas
Ta
F
<style>
..theTableClass
{
border: groove;
}
</style>
<table id=theTable class=theTableClass>
<tr id=realOne>
<td class=Bob sue>Some random text </td>
<td class=Sue>Some random text </td>
<td class=Sue>Some random text </td>
</tr>
</table>
<input type=button value=pressme onclick=SwapColumnsAndRows('theTable')>
<script>
function SwapColumnsAndRows(tableId)
{
var theTable = document.getElementById(tableId)
if(theTable == null) return;
var theTable2 = document.createElement("table");
var numRows = theTable.rows.length;
var numCells = theTable.rows[0].cells.length;
for(var i=0; i<numCells; i++)
{
var newRow = theTable2.insertRow(-1)
for(var j=0; j<numRows; j++)
{
var cell = theTable.rows[j].cells;
//var newCell = theTable2.rows.insertCell(-1);
var newCell = newRow.insertCell(-1);
SwapCells(cell, newCell);
}
}
while (theTable.rows.length > 0)
{
theTable.deleteRow(0);
}
var numRows = theTable2.rows.length;
var numCells = theTable2.rows[0].cells.length;
for(var i=0; i<numRows; i++)
{
var newRow = theTable.insertRow(-1)
for(var j=0; j<numCells; j++)
{
var cell = theTable2.rows.cells[j];
//var newCell = theTable.rows.insertCell(-1);
var newCell = newRow.insertCell(-1);
SwapCells(cell, newCell);
}
}
while (theTable2.rows.length > 0)
{
theTable2.deleteRow(0);
}
}
function SwapCells (cell1, cell2)
{
var dummyCell;
if (document.createElement && (dummyCell = document.createElement('td')))
{
cell1.parentNode.replaceChild(dummyCell, cell1);
cell2.parentNode.replaceChild(cell1, cell2);
dummyCell.parentNode.replaceChild(cell2, dummyCell);
}
}
</script>
Sorry but to view the code below you'll have to copy it into a temp.html file,
haven't access to a online web page anymore.
The code switches the rows and columns of a table. Its been tried in the
versions below. Note that it works in the latest version of IE before SP2,
whats changed?
By not working I mean that it'll switch the columns/rows twice then lose
some of the information? Can fix it by substituting the commented out lines
for the ones above.
mozilla 1.7.2, works
firefox 0.9.3, works
IE6.0.2800, works
IE6.0.2900, doesn't work
Any ideas
Ta
F
<style>
..theTableClass
{
border: groove;
}
</style>
<table id=theTable class=theTableClass>
<tr id=realOne>
<td class=Bob sue>Some random text </td>
<td class=Sue>Some random text </td>
<td class=Sue>Some random text </td>
</tr>
</table>
<input type=button value=pressme onclick=SwapColumnsAndRows('theTable')>
<script>
function SwapColumnsAndRows(tableId)
{
var theTable = document.getElementById(tableId)
if(theTable == null) return;
var theTable2 = document.createElement("table");
var numRows = theTable.rows.length;
var numCells = theTable.rows[0].cells.length;
for(var i=0; i<numCells; i++)
{
var newRow = theTable2.insertRow(-1)
for(var j=0; j<numRows; j++)
{
var cell = theTable.rows[j].cells;
//var newCell = theTable2.rows.insertCell(-1);
var newCell = newRow.insertCell(-1);
SwapCells(cell, newCell);
}
}
while (theTable.rows.length > 0)
{
theTable.deleteRow(0);
}
var numRows = theTable2.rows.length;
var numCells = theTable2.rows[0].cells.length;
for(var i=0; i<numRows; i++)
{
var newRow = theTable.insertRow(-1)
for(var j=0; j<numCells; j++)
{
var cell = theTable2.rows.cells[j];
//var newCell = theTable.rows.insertCell(-1);
var newCell = newRow.insertCell(-1);
SwapCells(cell, newCell);
}
}
while (theTable2.rows.length > 0)
{
theTable2.deleteRow(0);
}
}
function SwapCells (cell1, cell2)
{
var dummyCell;
if (document.createElement && (dummyCell = document.createElement('td')))
{
cell1.parentNode.replaceChild(dummyCell, cell1);
cell2.parentNode.replaceChild(cell1, cell2);
dummyCell.parentNode.replaceChild(cell2, dummyCell);
}
}
</script>