473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

<div> tag.innerHTML with table content not working

I have a table (with tabular data) that I want to display on a webpage.
Initially the talbe is empty. When a user clicks on a button, a child
window opens up with a form and some text fields. Then, the user clicks
submit on this child window, closing the child and sending the information
back to the parent.

That part works.

Now, I want to have the parent window change the innerHTML of a div tag that
I have nested in the table like so...

<table>
<div id="someid"></div>
</table>

The idea is, that each time someone clicks submit from one of the children,
the content of the div gets updated... and that works too!!!

But, when I assign it like this:
myVar.innerHTML="<tr><td>data1</td><td>data2</td><td>data3</td></tr>";
the row does not appear in the table, but above it. How can I fix this?

I know I can add <table ....> and </table> to the innerHTML, but I have
column headers that show initially and I would rather avoid having all of
the table created with js.

Any help is greatly appreciated.
Jul 23 '05 #1
1 10264
Sean wrote:
I have a table (with tabular data) that I want to display on a webpage.
Initially the talbe is empty. When a user clicks on a button, a child
window opens up with a form and some text fields. Then, the user clicks
submit on this child window, closing the child and sending the information
back to the parent. .... But, when I assign it like this:
myVar.innerHTML="<tr><td>data1</td><td>data2</td><td>data3</td></tr>";
the row does not appear in the table, but above it. How can I fix this?


You can't use innerHTML to add rows or cells to a table in IE.
Either use DOM and createElement to add rows & cells, or clone
an existing row and modify the content.
<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp>

For browser-neutral, W3C compliant assistance:

<URL:http://www.mozilla.org/docs/dom/technote/tn-dom-table/>

--
Fred
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
7
by: Herbman | last post by:
Hi, I'm trying to position a <tr> ("row") element with CSS. The table itself is positioned with <div> tags. The problem is when I use <div> tags to position the rows within the table nothing...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
2
by: Rodney Dunning | last post by:
Forgive me if this is a stupid question. I have a course syllabus located at http://www.longwood.edu/staff/dunningrb/teaching/easc101f06/easc101f06_syllabus.html. I use a <divcontainer for...
7
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it...
2
by: vidyasada | last post by:
Hi i m new to javascript . i need a script to srcoll the <div> content vertically within the <div> and it stops few seconds at the end of the content .. and again starts scrolling.. please...
5
by: chakradhari.ashish | last post by:
Does anybody know how can I load an html page inside a <div</div> where the content gets update on the onclick even of anchor <a href=> </a>? I googled around and followed some links pointing me...
10
by: Summercoolness | last post by:
so i am starting to use more of <br /and <div style="clear: both" / which is the XHTML style... now, won't those actually confuse the old browsers? for example, will the old browser treat the...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.