Monday, February 26, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  123] [ 4]  / answers: 1 / hits: 42968  / 15 Years ago, tue, february 17, 2009, 12:00:00
function DeleteData(ID)
{
var ctrlId=ID.id;

var divcontents=document.getElementById(ctrlId).innerHTML;
var tabid=ctrlId.replace(/div/,'tab');
var tabcontents=document.getElementById(tabid).innerHTML;
alert(document.getElementById(tabid).innerHTML);
document.getElementById(tabid).innerHTML=<TBody><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr></TBody>;
document.getElementById(ctrlId).innerHTML='';

}


I am trying to replace the Table with empty table but



document.getElementById(tabid).innerHTML=<TBody><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr></TBody>;


this line is causing Unknown Runtime Error


More From » debugging

 Answers
34

You can't set value to a table's innerHTML, you should access to child cells or rows and change them like that :



document.getElementById(tabid).rows[0].cells.innerHTML = 'blah blah';


For more info/example : Table, TableHeader, TableRow, TableData Objects


[#99968] Monday, February 9, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zackeryzainv

Total Points: 61
Total Questions: 102
Total Answers: 99

Location: Andorra
Member since Sat, May 27, 2023
10 Months ago
;