add id tag with setAttribute generates escape char
I am having some strange problems with a script, but am pretty sure that there is an obvious answer! The function below add a new row to a table.
The problem is that i can't access the new ID tag later in my code. I'm calling the function like so:
AddTableRow('tb_test', 'vendas' + arrVendas.length, new Array codigo_barras,"","", "", "", "", "", ""));
so i expect my new row to look like:
<TR ID="VENDAS1"></TR>
but it actually end up like so:
<TR ID=\"VENDAS1\"></TR>
Any ideas on how i can either set the attribute without the strage escape characters or how to access the ID if the characters remain?
Thanks for any help!!
Here's my function:
function AddTableRow(TableID, rowID, rowContent)
{
var table = document.getElementById(TableID);
var columns = table.childNodes(0).getElementsByTagName('TD');
var rows = table.getElementsByTagName('TR').length;
//alert('rows: ' + rows);
//criar nova row
var tr = document.createElement('TR');
//criar colunas da row
for(var i=0; i<columns.length; i++)
{
var td = document.createElement('TD');
try
{
td.innerHTML = rowContent[i];
}
catch(err)
{
}
tr.appendChild(td);
}
tr.setAttribute('ID', rowID);
table.appendChild(tr);
}
|