473,396 Members | 1,871 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,396 software developers and data experts.

Setting innerHTML reformats table

I have some column headings whose widths are set via styles:

<TR>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD class="head1" style="WIDTH: 120px">Stage</TD>
<TD class="head1" style="WIDTH: 90px">Est. Hours</TD>
<TD class="head1" style="WIDTH: 90px">Est. Delivery</TD>
<TD class="head1" style="WIDTH: 90px">Est. Cost</TD>
<TD class="head1" style="WIDTH: 200px">Comment</TD>
</TR>

When I set the value of a span in a cell using javascript

<TD><Span class="head1" id="TotalHours"
style="width:60px;text-align:right"></span></TD>

idTotal = document.getElementById("TotalHours");
idTotal.innerHTML = total;

all of the table columns shrink to the minimum size for the content,
ignoring the style width settings. Any suggestion as to why this might
be the case?

Thank you.

Jun 25 '06 #1
5 4595
ge****@boundvortex.com wrote:
I have some column headings whose widths are set via styles:

<TR>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD class="head1" style="WIDTH: 120px">Stage</TD>
<TD class="head1" style="WIDTH: 90px">Est. Hours</TD>
<TD class="head1" style="WIDTH: 90px">Est. Delivery</TD>
<TD class="head1" style="WIDTH: 90px">Est. Cost</TD>
<TD class="head1" style="WIDTH: 200px">Comment</TD>
</TR>

When I set the value of a span in a cell using javascript

<TD><Span class="head1" id="TotalHours"
style="width:60px;text-align:right"></span></TD>

idTotal = document.getElementById("TotalHours");
idTotal.innerHTML = total;

all of the table columns shrink to the minimum size for the content,
ignoring the style width settings. Any suggestion as to why this might
be the case?


I don't think this has anything to do with JavaScript. You have an
interaction between the HTML you are inserting, the head1 class, the
inline styles and whatever other style attributes that might be
inherited. You haven't shown the head1 style, or whatever else may be
affecting the table style-wise.

Trying asking in a CSS group:

news:comp.infosystems.www.authoring.stylesheets

They will appreciate a link to a page displaying the behaviour, or you
might post a minimal example.
--
Rob

Jun 26 '06 #2

Why does it happen? reflowing issues on the user-agent, specifically the one I've seen that is
Internet Explorer after doing some .innerHTML rewrites, not in geckos/opera, but in my case it
was white space property. I haven't bothered with it, since most times it works and I'm
assuming is some event being triggered upon a reflow, which omits the property, a Bug in IE
IMO, to be fixed at a newer version or service pack.

Danny
Jun 26 '06 #3
Danny wrote on 26 jun 2006 in comp.lang.javascript:
Why does it happen?


Why does what happen?

Please quote on usenet.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 26 '06 #4
ge****@boundvortex.com wrote:
When I set the value of a span in a cell using javascript
all of the table columns shrink to the minimum size for the content,
ignoring the style width settings. Any suggestion as to why this might
be the case?


Tables are flexible by design. Add table-layout:fixed to table's style to prevent this.
Visit w3c to see how it works...

Mitja
Jun 26 '06 #5
ge****@boundvortex.com wrote:
I have some column headings whose widths are set via styles:

<TR>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD style="visibility:hidden;width:0px">&nbsp;</TD>
<TD class="head1" style="WIDTH: 120px">Stage</TD>
<TD class="head1" style="WIDTH: 90px">Est. Hours</TD>
<TD class="head1" style="WIDTH: 90px">Est. Delivery</TD>
<TD class="head1" style="WIDTH: 90px">Est. Cost</TD>
<TD class="head1" style="WIDTH: 200px">Comment</TD>
</TR>

When I set the value of a span in a cell using javascript

<TD><Span class="head1" id="TotalHours"
style="width:60px;text-align:right"></span></TD>
How are you changing this?

What you show there has no style attribute for the <TD>. I also don't
see that cell anywhere in the sample.

I think you may need to provide more information. How about a link to
the page in question?
idTotal = document.getElementById("TotalHours");
idTotal.innerHTML = total;

all of the table columns shrink to the minimum size for the content,
ignoring the style width settings. Any suggestion as to why this might
be the case?


Difficult to say without seeing the actual code.

--
"The most convoluted explanation that fits all the available and made-up
facts is the most likely to be believed by conspiracy theorists"
Jun 26 '06 #6

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

Similar topics

5
by: Soren Vejrum | last post by:
I am working on a web-based html editor using MSIE's designmode and iframes. Everything works just fine, but MSIE changes all my relative "a href" and "img src" links (i.e. "/index.asp") to...
4
by: harry | last post by:
Using IE 5.5 (sp2) - no other I have a table that need's to be sorted by single column using javascript. I have the code to do this but because of the attributes associated with the <tr>...
4
by: RobG | last post by:
I know you aren't supposed to use innerHTML to mess with table structure, but it seems you can't use it just after a table without damaging the containing element. I added a table to a div using...
4
by: bissatch | last post by:
Hi, I have the following simple HTML page. I am trying to get the innerHTML of the table element, "xmltable". I do intend to change the innerHTML of this table but at this stage I am having...
1
by: tpirkle | last post by:
I have an html table based form that has textboxes embedded in table rows on it. I wanted to have the textboxes autosize and also have the table rows autosize. To accomplish this, I added a...
7
by: Nez | last post by:
Help needed! Hello, I have looked everywhere for a solution to my problem and this is pretty much my last resource. I have created a table in a span with the innerhtml command in my code behind....
1
by: huzheng001 | last post by:
I have develop a on-line dictionary website, http://www.stardict.org I meet a problem: Here is two lines of js codes: document.getElementById("wordlist").innerHTML = "";...
8
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this...
1
by: Tarik Monem | last post by:
I have been able to successfully retrieve data from an xml file, where the data has been massaged a little bit, to create a table to be retrieved and it is displayed via a document.writeln within a...
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: 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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.