473,396 Members | 1,938 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.

Getting Elements and Contents of a subset of the Document

Dear Sirs,

Any idea how I can work this out.?

In my document I have a table row with an unknown number and type of
elements.
I want to make a set of name-value pairs contained in this table row,
while I do not know the names of the elements in advance.

Is there something like "give me all children of this table row"?
Can I get all children in the document with a wildcard 'Subname*', like
give me all elements starting with 'Subname' ?

It's for an Intranet so the browsers could only be IE 6.

Marc Wentink

Apr 12 '06 #1
7 2128


marc wrote:
In my document I have a table row with an unknown number and type of
elements.
A HTML table row, a tr element? The number of child elements can be
unknown but the type of child elements can only be td or th.
And a table row element objects has a cells collection that allows you
to access the cells, whether they are td or th elements.

Is there something like "give me all children of this table row"?


Children should be th or td elements accessible in the cells collection.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 12 '06 #2
marc said on 13/04/2006 1:48 AM AEST:
Dear Sirs,

Any idea how I can work this out.?

In my document I have a table row with an unknown number and type of
elements.
I want to make a set of name-value pairs contained in this table row,
while I do not know the names of the elements in advance.

Is there something like "give me all children of this table row"?
Can I get all children in the document with a wildcard 'Subname*', like
give me all elements starting with 'Subname' ?
Further to Martin's response, you can also use:

var allDecendents = trRef.getElementsByTagName('*');
Then sift through all the elements. But that seems rather a strange way
to go about it, as the returned collection will have had nearly all the
document structure removed.

It's for an Intranet so the browsers could only be IE 6.


getElmenetsByTagName() is almost fully supported by IE 5.x, if the
parameter is '*' IE5.x will always return an empty collection. IE4
doesn't support getElementsByTagName at all.
--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 13 '06 #3
Martin:
Children should be th or td elements accessible in the cells collection.


That would be? The childNodes property of the TR element, right? I
am/was missing the right name of such a propery and then it's difficult
to find information. I am not really that experienced in Javascript I
would know the name of such a property or function.

Thanks a lot for the hint. Marc Wentink

Apr 13 '06 #4


marc wrote:
Martin:

Children should be th or td elements accessible in the cells collection.

That would be? The childNodes property of the TR element, right?


No, the cells collection, that is a property named cells:
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-67349879>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 13 '06 #5

"marc" <ma*********@hotmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Dear Sirs,

Any idea how I can work this out.?

In my document I have a table row with an unknown number and type of
elements.
I want to make a set of name-value pairs contained in this table row,
while I do not know the names of the elements in advance.

Is there something like "give me all children of this table row"?
Can I get all children in the document with a wildcard 'Subname*', like
give me all elements starting with 'Subname' ?


Seems easier to replace the entire *table* or *tr* contents with the new
values.
Build the string consisting of all the tr and td tags and their contents -
and use that string to replace the innerHTML of the table element. - OR
replace all the innerHTML of the <tr> element.
whatchathink? ( my 2¢)
Hal
Apr 14 '06 #6
Hal:
Seems easier to replace the entire *table* or *tr* contents with the new
values.


No, that is not what I want.

I want to get a few values in the form, send them to the CGI server,
and save some data, in between, without submitting the whole form. And
also without rewriting the whole HTML on the client side. Apart from
saving some data on the server database, the rest of the HMTL page on
the client side does not even change, hence I do not want to redraw
this screen, hence I do not want any new values in that table.

Apr 18 '06 #7
Rob:
Further to Martin's response, you can also use: var allDecendents = trRef.getElementsByTagName('*');
Then sift through all the elements. But that seems rather a strange way
to go about it, as the returned collection will have had nearly all the
document structure removed.


Actually that is perfect since I do not care about the document
structure, I just want a non submit call to the server to save some
data, while the whole html table does not change at all. The id of the
data is in the cell name, and it does not matter where in the html
table it appears.

Apr 20 '06 #8

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

Similar topics

4
by: Leif K-Brooks | last post by:
I'm writing a site with mod_python which will have, among other things, forums. I want to allow users to use some HTML (<em>, <strong>, <p>, etc.) on the forums, but I don't want to allow bad...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
37
by: ajay | last post by:
How to make a web page getting refreshed after a given time interval automatically. HTML Code plz. Tx Ajay
4
by: WindAndWaves | last post by:
Hi Gurus I have the following statement in my code: var e = form.elements; Is it possible to put any conditions on this statement. What I actually want to say is: var e = form.elements...
12
by: Adam Lipscombe | last post by:
Folks, I need to get the contents of a form attribute. In Read/Write mode this is field, so I can use getElementById("name").value In ReadOnly this is just plain text, so I can use...
4
by: ioneabu | last post by:
The below function attempts to remove the contents of one form and replace with the contents of another. Is this not possible? Why not? It will make a big difference in the final solution to a...
3
by: robert.oschler | last post by:
I have an AJAX driven page where I dynamically add rows to a known table on the page, based on the return document from the AJAX call, using DOM node methods (except for a small snippet of code,...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
4
by: SteveKlett | last post by:
I have a subset of form items that I need to perform different operations on (enable/disable, clear values, change style, etc) rather than hard code the IDs or names I would like to recursively...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
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,...
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.