M
M.L.
Basically I'm trying to convert a paragraph within a table cell into a
textarea within that same cell, keeping the paragraph text intact.
However, when I pass the text string to a function called
makeTextarea, both Firefox and IE8 give me the error: 'test_text' is
undefined. I need help determining what I'm doing wrong. Thanks.
function calcRows()
{
var tbody =
document.getElementById("myTable").getElementsByTagName("tbody")[0];
var numRows = tbody.rows.length;
for (var counter = 0; counter < numRows; counter++)
{
if
(tbody.rows[counter].cells[1].getElementsByTagName("textarea")[0])
{
var ptext = "test_text";
tbody.rows[counter].cells[1].innerHTML = '<p
onClick="makeTextarea('+counter+','+ptext+')">'+ptext+'</p>';
}
}
}
function makeTextarea(rownum,mytext)
{
var tbody =
document.getElementById("myTable").getElementsByTagName("tbody")[0];
tbody.rows[rownum].cells[1].innerHTML = '<textarea
name="item_name_"'+rownum+'" class="border3b" rows="5"
maxlength="500">'+mytext+'</textarea>';
}
textarea within that same cell, keeping the paragraph text intact.
However, when I pass the text string to a function called
makeTextarea, both Firefox and IE8 give me the error: 'test_text' is
undefined. I need help determining what I'm doing wrong. Thanks.
function calcRows()
{
var tbody =
document.getElementById("myTable").getElementsByTagName("tbody")[0];
var numRows = tbody.rows.length;
for (var counter = 0; counter < numRows; counter++)
{
if
(tbody.rows[counter].cells[1].getElementsByTagName("textarea")[0])
{
var ptext = "test_text";
tbody.rows[counter].cells[1].innerHTML = '<p
onClick="makeTextarea('+counter+','+ptext+')">'+ptext+'</p>';
}
}
}
function makeTextarea(rownum,mytext)
{
var tbody =
document.getElementById("myTable").getElementsByTagName("tbody")[0];
tbody.rows[rownum].cells[1].innerHTML = '<textarea
name="item_name_"'+rownum+'" class="border3b" rows="5"
maxlength="500">'+mytext+'</textarea>';
}