Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing table tags to innerHTML

Status
Not open for further replies.
Nov 12, 2001
2
0
0
US
I am trying to update the contect of a <DIV> in IE using innerHTML to write HTML to it. It seems to accept most tags okay, but is ignoring anything to do with tables (TD, TR, TABLE).

document.all[&quot;divName&quot;].innerHTML = &quot;<TABLE><TR><TD>cell1</TD></TR><TR><TD>cell2</TD></TR></TABLE>&quot;;

would yield:
cell1cell2

How do I go about passing table-related tags?
 
function WriteOutDiv()
{
var t=&quot;<table><tr><td id=TD1> Test Cell</td></tr></table>&quot;;
document.all.item(&quot;tesDiv&quot;).innerHTML=t;
}

<div id=tesDiv style=&quot;visibility:visible;display:block&quot;>
<img src=&quot;dothide.gif&quot; onclick=&quot;WriteOutDiv()&quot;>
</div>
Hope it helps:)
 
I figured out my problem... I was not including the <TABLE> tag in the same statement. I didn't realize that the statements don't concatenate. Solved by creating a string to output all at once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top