Hi all. Hope your week is going well so far.
I have a table which is dynamically filled by isapi/cgi with values from a Db.
Each row of the table is to have an "edit" button, which is to allow that row to become editable (the button would then become a "save" button). I have found the following code which will set a table cell to be editable on click of the cell, and i would like to "tweak" it to do what i need. (ie pass the <tr> as "this" and loop through <td>'s???)
cheers guys
Tracey
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!
I have a table which is dynamically filled by isapi/cgi with values from a Db.
Each row of the table is to have an "edit" button, which is to allow that row to become editable (the button would then become a "save" button). I have found the following code which will set a table cell to be editable on click of the cell, and i would like to "tweak" it to do what i need. (ie pass the <tr> as "this" and loop through <td>'s???)
Code:
function editCell (cell) {
if (document.all) {
cell.innerHTML =
'<INPUT ' +
' ID="editCell"' +
' ONCLICK="event.cancelBubble = true;"' +
' ONCHANGE="setCell(this.parentElement, this.value)" ' +
' ONBLUR="setCell(this.parentElement, this.value)" ' +
' VALUE="' + cell.innerText + '"' +
' class="medtext"' +
'>';
document.all.editCell.focus();
document.all.editCell.select();
}
else if (document.getElementById) {
cell.normalize();
var input = document.createElement('INPUT');
input.setAttribute('value', cell.firstChild.nodeValue);
input.setAttribute('size', cell.firstChild.nodeValue.length);
input.onchange = function (evt) { setCell(this.parentNode,
this.value); };
input.onclick = function (evt) {
evt.cancelBubble = true;
if (evt.stopPropagation)
evt.stopPropagation();
};
cell.replaceChild(input, cell.firstChild);
input.focus();
input.select();
}
}
function setCell (cell, value) {
if (document.all)
cell.innerText = value;
else if (document.getElementById)
cell.replaceChild(document.createTextNode(value), cell.firstChild);
}
cheers guys
Tracey
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!