Hi,
I have a reference to a dom table.
How can I retrieve the number of columns in that table ?
The stop value below doesn't work, nor did my experimenting with
tbodies[0] and childNodes..
....
var thistable = document.getEle mentById('resul taattbl');
for (var j=0, stop = thistable.tbody .rows[0].length; j<stop; j++) {
....
I find it bizar that the tbody shortcut works in this instance :
thistable.tbody .appendChild(ne wRow);
but not in the above for loop.
thx
Ward 6 4994
Ward Germonpré wrote: I have a reference to a dom table. How can I retrieve the number of columns in that table ?
Depends on how you define that (as cells can span multiple rows in HTML
tables) but you can at least read out
table.rows[0].cells.length
to find out the number of cells in the first row.
--
Martin Honnen http://JavaScript.FAQTs.com/
Ward Germonpré wrote: Hi,
I have a reference to a dom table. How can I retrieve the number of columns in that table ? The stop value below doesn't work, nor did my experimenting with tbodies[0] and childNodes..
... var thistable = document.getEle mentById('resul taattbl'); for (var j=0, stop = thistable.tbody .rows[0].length; j<stop; j++) { ...
I find it bizar that the tbody shortcut works in this instance :
thistable.tbody .appendChild(ne wRow);
but not in the above for loop.
tBodies[0].rows.length // watch the case
AFAIK HTML Table doesn't have "all rows of any kind in this table"
property. Rows appertain either to tHead section or to tFoot section or
to one of tBody sections (can be as many tBodies as you want). In the
most primitive case like <table><tr><td> content</td></tr></table> and
such tHead and tFoot sections are not defined and a single tBody
section will be added automatically. In such case
tableRef.tBodie s[0].rows.length-1 will be equal to the amount of rows
in the given table. In more complex cases (multiple tBodies, tHead
and/or tFoot) you have to calculate everything separately.
Martin Honnen <ma*******@yaho o.de> wrote in news:44686de6$0 $4514$9b4e6d93
@newsread2.arco r-online.net:
Ward Germonpré wrote:
I have a reference to a dom table. How can I retrieve the number of columns in that table ?
Depends on how you define that (as cells can span multiple rows in HTML tables) but you can at least read out table.rows[0].cells.length to find out the number of cells in the first row.
Thx Martin, that was it.
Ward
VK wrote: Ward Germonpré wrote: Hi,
I have a reference to a dom table. How can I retrieve the number of columns in that table ? The stop value below doesn't work, nor did my experimenting with tbodies[0] and childNodes..
... var thistable = document.getEle mentById('resul taattbl'); for (var j=0, stop = thistable.tbody .rows[0].length; j<stop; j++) { ...
I find it bizar that the tbody shortcut works in this instance :
thistable.tbody .appendChild(ne wRow);
but not in the above for loop. tBodies[0].rows.length // watch the case
The OP wants the number of columns, not rows. The tbody element may not
contain all the rows in table (though it can).
AFAIK HTML Table doesn't have "all rows of any kind in this table" property.
The rows collection (an object, not a property) of a table element
contains *all* the rows in the table.
HTMLTableElemen t
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-64060425>
table rows
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-6156016>
Rows appertain either to tHead section or to tFoot section or to one of tBody sections (can be as many tBodies as you want).
tbody, thead and tfoot elements implement the table section interface,
their rows collections contain just the rows in their section of the
table. If a table has no thead or tfood and only one tbody (implied or
explicit), the the tbody's rows collection will be the same as the table's.
HTMLTableSectio nElement
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-67417573>
table section rows
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-52092650>
In the most primitive case like <table><tr><td> content</td></tr></table> and such tHead and tFoot sections are not defined and a single tBody section will be added automatically. In such case tableRef.tBodie s[0].rows.length-1 will be equal to the amount of rows in the given table. In more complex cases (multiple tBodies, tHead and/or tFoot) you have to calculate everything separately.
No, you don't; you can use the table's rows collection.
--
Rob
RobG wrote: In more complex cases (multiple tBodies, tHead and/or tFoot) you have to calculate everything separately.
No, you don't; you can use the table's rows collection.
Hah! So I was overly accurate with the DOM all this time. Nice to know.
RobG wrote: VK wrote: AFAIK HTML Table doesn't have "all rows of any kind in this table" property.
The rows collection (an object, not a property) of a table element contains *all* the rows in the table.
JFTR, `rows' "is" both: a property of HTMLTableElemen t/
HTMLTableSectio nElement objects (because it is an attribute
of the HTMLTableElemen t/HTMLTableSectio nElement interface),
and (a reference to) a HTMLCollection object (with items
consisting of references to HTMLTableRowEle ment objects).
PointedEars
-- http://members.ud.com/download/gold/ http://folding.stanford.edu/ http://alien.de/seti/ http://setiathome.ssl.berkeley.edu/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ajay Garg |
last post by:
What is the way we could implement a business logic from a Table by
storing it statemnnets in a colums and defining an execute sql to
execute it.Some legal requirements make it diffcult for us to create
modify stored procdures so Iwant to have a process where we create new
rows in a table and execute it to execute business logic.
All views are welcome.
Havin g one table two tables different approaches to store ststements
|
by: Phil Rutter |
last post by:
Hello All,
I have about 700 word documents that have 2 tables one is static
4 colums x 5 rows the other is 5 colums x rows ranging from 2 to 100
what i wolud like to do is open the word doc.
import the first word table then import the second word table close
word doc
open next word doc and repeat process.
i am able to import one set of data currently into an excel spread
sheet
but how can i loop through all the documents and import them...
|
by: Eric |
last post by:
Hello,
I have a Existing table with three columns that have a data type of
string. I want to write VBA code that will modify one of the colums to
DataType of Number.
Also, I'm looking for code to add a column to the table.
ANy suggestions would be appreciated.
Thanks
|
by: Ruby Tuesday |
last post by:
Hi, I was wondering if expert can give me some lite to convert my word table
into access database.
Note: within each cell of my word table(s), some has multi-line data in it.
In addition, there is one row containing picture(s) as well.
So far, what I did is doing it manually for each word docs I have.
Select Table
Convert Table to Text(I use ^ character for delimiter)
|
by: phil-news-nospam |
last post by:
Is there really any advantage to using DIV elements with float style
properies, vs. the old method of TABLE and TR and TD?
I'm finding that by using DIV, it still involves the same number of
elements in the HTML to get everything just right. When you consider
the class attribute on the DIV elements, there's not much size savings
anymore for using DIV.
There are other disadvantages to not using TABLE/TR/TD, such as the
lack of ability...
| |
by: Nico VanHaaster |
last post by:
Hello all.
There is what i would like to do, I have a page that pulls all the
hours for our staff over a given period calculated them and reports
back on 15 different colums and is aproximatly 500 individual rows of
data for a table. Now as you could imagine that is a night mare to look
at for anyone, i have done a few things to make remeber which columns
are which however a simple Solution would be to the top row, or rows i
define stay...
|
by: ravindarjobs |
last post by:
Hello friends,
I am using ms access 2003, and Vb6.
i am displaying a table in a form as pivot table (following "Auto Form: Pivot Table" Wizard)
Usually i select the items i want to be displayed in the pivot table by dragging them on to the pivot Table from Pivot Fields.
But i got a Problem.
My table wil have Columns Dynamically.
i mean the colums may increase and decrease from time to time.
so my requirement is to display the Updated...
|
by: Harshpandya |
last post by:
Here is my code for look up table - where i am planning to built 10 colums and 8 rows and put array values in the table boxes. Problem is - it is only printing the last array valules instead of all
var maxRow = 10;
var maxCol = 8;
var height1 = 480;
var width1 = 640;
function CenteringError(Xe, Ye){
var table = new Array ( (, , , , , , , , , ),
|
by: jrod11 |
last post by:
hi,
I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes.
There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)?
Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html
Here is some jquery js that I think...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |