473,395 Members | 2,446 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.

Accessing Table Cells Within Nested Frames

G'Day All

I am having trouble dynamically assigning a value to a table's cell
from one frame to another frame.

I've created a website that is primarily viewed in a frameset
consisting of 2 frames - a navigation frame (navFrame) at the top and
a contents frame (mainFrame) on the bottom. In all instances, the
mainFrame displays a single page except in one case, where it was
necessary to use a frameset consisting of a left frame (controlFrame)
and a right frame (tableFrame).

The tableFrame contains an HTML table used to display items that are
added or removed using the controlFrame through the use of JavaScript
functions. This used to be on a single page and all worked fine, but
it became necessary to break it out into frames since the tableFrame
required scrolling and I didn't want the controlFrame contents to
scroll out of sight.

In the controlFrame, there is a ListBox (cbSelection) and buttons to
perform things like ClearTable, SaveTable, etc. If I can get the
adding of data to the table done, the rest should fall into place and
this is where your help can get me throught it.

Initially, when all was on a single page, the following code performed
as expected:

Expand|Select|Wrap|Line Numbers
  1. .... Variable Declarations and Intializations ...
  2.  
  3. iIndex = document.Form1.cbSelection.selectedIndex
  4. strItem = document.Form1.cbSelection.options[iIndex].text
  5. strContent = document.Form1.cbSelection.options[iIndex].value;
  6.  
  7. strTableCell = "R" + iRow + "C" + iColumn;
  8. document.getElementById(strTableCell).innerHTML = strItem;
  9.  
  10. strTableCell = "R" + iRow + "C" + (iColumn + 1);
  11. document.getElementById(strTableCell).innerHTML = strContent;
  12.  

After reading through the NG's to get an idea of how to proceed with
communicating across frames, I have tried (and failed to get working)
the following methods:

Expand|Select|Wrap|Line Numbers
  1. parent.document.frames["tableFrame"].getElementById(strTableCell).innerHTML
  2. = strContent;
  3.  
Expand|Select|Wrap|Line Numbers
  1. parent.document.frames.item('tableFrame').getElementById(strTableCell).innerHTML
  2. = strContent;
  3.  
Expand|Select|Wrap|Line Numbers
  1. parent.document.frames['tableFrame'].getElementById(strTableCell).innerHTML
  2. = strContent;
  3.  
Expand|Select|Wrap|Line Numbers
  1. parent.document.tableFrame.getElementById(strTableCell).innerHTML =
  2. strContent;
  3.  
Expand|Select|Wrap|Line Numbers
  1. top.mainFrame.tableFrame.getElementById(strTableCell).innerHTML =
  2. strContent;
  3.  
Expand|Select|Wrap|Line Numbers
  1. parent.tableFrame.getElementById(strTableCell).innerHTML = strContent;
  2.  
Expand|Select|Wrap|Line Numbers
  1. window.mainFrame.tableFrame.getElementById(strTableCell).innerHTML =
  2. strContent;
  3.  

What am I doing wrong here? Am I somewhere in the ballpark with the
direction in which I'm trying to accomplish this task? Is there a
better way to do this?

Please post all answers to the newsgroup so that others might benefit
from your expertise as I am sure I'm not the only one to run into
this.
Cheers,
Chris.
Jul 20 '05 #1
2 6639
> > I am having trouble dynamically assigning a value to a table's cell
from one frame to another frame.

value? A text node or html markup?


Guess I should have clarified this - Entering Text in the table cells.

When a page design is a bit complex, then providing an url is best in
this newsgroup (and in other web design newsgroups). It saves so much
time to experts and regulars of newsgroups. I know that many regulars
and experts in this newsgroup can read the code of a page as well as you
can read a newspaper headlines.
This is a good point and it is well taken, but I do not have a WWW DNS
entry and my IP Address is dynamic which is why I tried to explain it
as best I could. Perhaps next time I should include a picture like:

_______________________________________________
( )
( navFrame )
(_______________________________________________)
( )
( mainFrame )
( ___________________________________________ )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( controlFrame ) tableFrame ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( (______________)____________________________) )
(_______________________________________________)
I encourage you to keep prefixing objects the way you do (and I have
adopted this code writing policy too):
i for integer, cb for combobox, str for string, etc...
This code writing policy helps tremendously debugging with software,
code maintenance, code reusability, code review by others, etc..


No need to encourage me in using Hungarian Notation. I am a strong
proponent in this style of coding and have been using and teaching it
for years. I believe in being able to read through code as if it were
"a story". I don't even shorten variable names, for example iCol, but
instead write out iColumn.

strTableCell = "R" + iRow + "C" + iColumn;
document.getElementById(strTableCell).innerHTML = strItem;


May I suggest here
document.getElementById(strTableCell).childNodes[0].nodeValue = strItem;
This will speed up parsing and rendering by at least 300% on all W3C web
standards compliant DOM 1 Character Data browsers: MSIE 5+, NS 6+, Opera
7.x, Konqueror 3, etc.


Thank-you very much for this information. Although I am aware that it
takes more time to parse using my original technique, I was surprised
to learn that a 300% increase was the benefit in your suggestion.
Knowledge is good and I am now putting it into practice.
Expand|Select|Wrap|Line Numbers
  1.  > parent.document.frames["tableFrame"].getElementById(strTableCell).innerHTML
  2.  > = strContent;
  3.  > 


Please try:
parent.frames["tableFrame"].document.getElementById(strTableCell).childNodes[0].nodeValue

And this was the answer I've been seeking. It appears I just had the
'document' and 'frames' components in the wrong place (aside from the
innerHTML/nodeValue).

Thanks again DU - you've been a great help!
Cheers,
Chris.
Jul 20 '05 #2
DU
Chris New wrote:
I am having trouble dynamically assigning a value to a table's cell
from one frame to another frame.

value? A text node or html markup?

Guess I should have clarified this - Entering Text in the table cells.


No prob. Your "str" prefix suggested it was TEXT_NODE, kinda answered
that question :)

When a page design is a bit complex, then providing an url is best in
this newsgroup (and in other web design newsgroups). It saves so much
time to experts and regulars of newsgroups. I know that many regulars
and experts in this newsgroup can read the code of a page as well as you
can read a newspaper headlines.

This is a good point and it is well taken, but I do not have a WWW DNS
entry and my IP Address is dynamic which is why I tried to explain it
as best I could. Perhaps next time I should include a picture like:

_______________________________________________
( )
( navFrame )
(_______________________________________________)
( )
( mainFrame )
( ___________________________________________ )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( controlFrame ) tableFrame ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( ( ) ) )
( (______________)____________________________) )
(_______________________________________________)

I encourage you to keep prefixing objects the way you do (and I have
adopted this code writing policy too):
i for integer, cb for combobox, str for string, etc...
This code writing policy helps tremendously debugging with software,
code maintenance, code reusability, code review by others, etc..

No need to encourage me in using Hungarian Notation. I am a strong
proponent in this style of coding and have been using and teaching it
for years. I believe in being able to read through code as if it were
"a story". I don't even shorten variable names, for example iCol, but
instead write out iColumn.


I am also a strong proponent of meaningful, intuitive variable
identifiers. :)
strTableCell = "R" + iRow + "C" + iColumn;
document.getElementById(strTableCell).innerHT ML = strItem;
May I suggest here
document.getElementById(strTableCell).childNodes[0].nodeValue = strItem;
This will speed up parsing and rendering by at least 300% on all W3C web
standards compliant DOM 1 Character Data browsers: MSIE 5+, NS 6+, Opera
7.x, Konqueror 3, etc.

Thank-you very much for this information. Although I am aware that it
takes more time to parse using my original technique, I was surprised
to learn that a 300% increase was the benefit in your suggestion.
Knowledge is good and I am now putting it into practice.


On a fast machine, the performance gain is negligeable but on a slow
(< 600Mhz) machine, this is where the performance gain is most
noticeable and the most welcomed.
Expand|Select|Wrap|Line Numbers
  1. parent.document.frames["tableFrame"].getElementById(strTableCell).innerHTML
  2. = strContent;

Please try:
parent.frames["tableFrame"].document.getElementById(strTableCell).childNodes[0].nodeValue


And this was the answer I've been seeking.


In your original post, you rightly mentioned that figuring out the DOM
logic was not evident and I think you have an important point here. Even
in books, the DOM logical view is not self-explanatory, easy to figure
out. I think comp.lang.javascript and other related web programming
newsgroups should build a DOM logical view which would serve as a
reliable reference, share it and put it in their respective FAQs so that
everyone can see it, consult it and refer others to it when needed.

I have several logical view images of the DOM event models (3), W3C DOM
2 interfaces, CSS2 box model, MSIE 5.x DHTML object model, etc.. These
are extremely useful. I'll upload them next week on my site in 1 section.

It appears I just had the 'document' and 'frames' components in the wrong place (aside from the
innerHTML/nodeValue).

Thanks again DU - you've been a great help!

Thank you for your nice comments: this is appreciated. :)
Glad I could help. :)

Cheers,
Chris.


take care

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #3

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

Similar topics

0
by: N. Demos | last post by:
I have a single row table with fixed dimensioned cells nested inside a fixed dimensioned div, which has overflow: hidden. The div's dimensions are such that It should only display the first two...
3
by: N. Demos | last post by:
I have a single row table with fixed dimensioned cells nested inside a fixed dimensioned div, which has overflow: hidden. The div's dimensions are such that It should only display the first two...
6
by: David D. | last post by:
I want to be able to access cells within an HTML table, via computed row number and column number. I was considering using oTableID.children and oTR.children arrays. My question is what...
15
by: Christopher Benson-Manica | last post by:
When are named elements written with script accessible to script? <html><head><script type="text/javascript"> function ready() { alert( document.getElementsByName("div").length ); }...
4
by: Stefan Mueller | last post by:
I have a table dynamically created with a JavaScript (insertRow, deleteRow). At the end I'd like to go through the whole table (beginning at the first and ending at the last row) to display all the...
2
by: Fred Flintstone | last post by:
Why not? Why can't I put a table within paragraph tags? Also: "Element DIV cannot be nested within element 'u'." I can't underline something within div tags? Why not? Thanks! :)
3
by: McKirahan | last post by:
I have a Web page that uses some JavaScript and CSS. I have specified a three column table with a fixed-width left and right side; the center colum expands to fill the page. Within this...
17
by: Grant Kelly | last post by:
I'm wondering if it's possible within HTML markup (or possibly CSS) to specify that an HTML table's headers should be placed 'over' the cell borders rather than 'within' the cells. For example...
8
by: phub11 | last post by:
Hi - I have a function which appends row(s) to the bottom of a table: function mouseUpHandler() { var table = document.getElementById("mytable"); var rowCount = table.rows.length; var...
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
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
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
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
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...
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.