<HTML>
<HEAD>
<SCRIPT>
var st=-1;
var tblOldCells = new Array(10);
function createText()
{
if(st!=-1)
{
var tblCells = document.getElementById("tid").rows[st].cells;
var j, len = tblCells.length;
for (j=0; j<len; j++)
{
tblCells[j].innerText = tblOldCells[j];
}
st = -1;
}
var t = event.srcElement;
st = t.parentElement.rowIndex;
var tblCells = document.getElementById("tid").rows[t.parentElement.rowIndex].cells;
var j, len = tblCells.length;
for (j=0; j<len; j++)
{
var oNewItem = document.createElement("input");
oNewItem.value=tblCells[j].innerText;
tblCells[j].innerText="";
tblCells[j].insertBefore(oNewItem);
tblOldCells[j] = oNewItem.value;
}
}
</SCRIPT>
</HEAD>
<BODY >
<table id="tid" border = "1" >
<tr onclick="createText()">
<td id="td1">Italy</td>
<td id="td2">UK</td>
<td id="td3">Spain</td>
</tr>
<tr onclick="createText()">
<td id="td4">USA</td>
<td id="td5" >Canada</td>
<td id="td6" >Mexico</td>
</tr>
<tr onclick="createText()">
<td id="td4">India</td>
<td id="td5" >China</td>
<td id="td6" >Japan</td>
<td id="td6" >Korea</td>
</tr>
</table>
<BODY>
</HTML>
<HEAD>
<SCRIPT>
var st=-1;
var tblOldCells = new Array(10);
function createText()
{
if(st!=-1)
{
var tblCells = document.getElementById("tid").rows[st].cells;
var j, len = tblCells.length;
for (j=0; j<len; j++)
{
tblCells[j].innerText = tblOldCells[j];
}
st = -1;
}
var t = event.srcElement;
st = t.parentElement.rowIndex;
var tblCells = document.getElementById("tid").rows[t.parentElement.rowIndex].cells;
var j, len = tblCells.length;
for (j=0; j<len; j++)
{
var oNewItem = document.createElement("input");
oNewItem.value=tblCells[j].innerText;
tblCells[j].innerText="";
tblCells[j].insertBefore(oNewItem);
tblOldCells[j] = oNewItem.value;
}
}
</SCRIPT>
</HEAD>
<BODY >
<table id="tid" border = "1" >
<tr onclick="createText()">
<td id="td1">Italy</td>
<td id="td2">UK</td>
<td id="td3">Spain</td>
</tr>
<tr onclick="createText()">
<td id="td4">USA</td>
<td id="td5" >Canada</td>
<td id="td6" >Mexico</td>
</tr>
<tr onclick="createText()">
<td id="td4">India</td>
<td id="td5" >China</td>
<td id="td6" >Japan</td>
<td id="td6" >Korea</td>
</tr>
</table>
<BODY>
</HTML>