473,786 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting innerHTML reformats table

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

<TR>
<TD style="visibili ty:hidden;width :0px">&nbsp;</TD>
<TD style="visibili ty:hidden;width :0px">&nbsp;</TD>
<TD style="visibili ty: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:60 px;text-align:right"></span></TD>

idTotal = document.getEle mentById("Total Hours");
idTotal.innerHT ML = 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 4605
ge****@boundvor tex.com wrote:
I have some column headings whose widths are set via styles:

<TR>
<TD style="visibili ty:hidden;width :0px">&nbsp;</TD>
<TD style="visibili ty:hidden;width :0px">&nbsp;</TD>
<TD style="visibili ty: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:60 px;text-align:right"></span></TD>

idTotal = document.getEle mentById("Total Hours");
idTotal.innerHT ML = 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.infos ystems.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.javas cript:
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****@boundvor tex.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****@boundvor tex.com wrote:
I have some column headings whose widths are set via styles:

<TR>
<TD style="visibili ty:hidden;width :0px">&nbsp;</TD>
<TD style="visibili ty:hidden;width :0px">&nbsp;</TD>
<TD style="visibili ty: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:60 px;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.getEle mentById("Total Hours");
idTotal.innerHT ML = 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
21634
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 absolute links (i.e. "http://localhost/index.asp") when I set the iframe's innerHTML. This is bad as the links are supposed to be relative. How can I avoid this? Any solutions/suggestions are much appreciated.
4
17231
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> element, when the sorted values are copied back in to the table I want to replace the entire row not just the inner values! Any ideas why this doesn't work?
4
6553
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 createElement methods, then added a bit of extra text using innerHTML, only to find most of the attributes removed from the table. Below is a script that calls the same code to add a table inside a div. It adds an onclick to the div and...
4
1766
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 simple problems. When I create the following page, note that 'onload' the loadfunction() function is run. In this function all that is happening is that it is chacking that the browser supports getElementById and then display an alert with the...
1
2552
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 user-defined function that counts the number of carriage return/line feeds and sets the textbox's Row property accordingly. This works to autosize the textbox. Also, I wanted the containing table row to autosize to show the full textbox. The reason...
7
2609
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. In this table I have created textbox html input fields. Now I need to allow the user to change the value in the textfield, and compare it to the old value I have stored in a cookie. Problem is, because the textfield was created in the code...
1
2199
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 = ""; document.getElementById("definition").innerHTML = "line1<br>line2"; The corresponding html codes are: <table width="100%"> <tr> <td width="25%" valign="top"><div id="wordlist" width="100%" style=' overflow-y:auto; height:352px;'></div></td>
8
3219
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 javascript is not working. e.g. html content:
1
4586
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 javascript file, but now I am going to go completely AJAX & using innerHTML to display the same information to the browser. First, snippets of the original code that was working with no problem: XML first: <title>bla bla</title> ...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.