473,662 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6661
> > 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.getEle mentById(strTab leCell).innerHT ML = strItem;


May I suggest here
document.getEle mentById(strTab leCell).childNo des[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.getEl ementById(strTa bleCell).childN odes[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. :)
strTableCe ll = "R" + iRow + "C" + iColumn;
document.get ElementById(str TableCell).inne rHTML = strItem;
May I suggest here
document.getEle mentById(strTab leCell).childNo des[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.fram es["tableFrame "].document.getEl ementById(strTa bleCell).childN odes[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.javas cript 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
1682
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 table cells. This all renders correctly in MSIE 6.x, but doesn't in Firefox. In Firefox, the cell widths are reduced so that all the cells are displayed within the div frame. I've played around with this: commenting out css properties to see if...
3
5899
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 table cells. This all renders correctly in MSIE 6.x, but doesn't in Firefox. In Firefox, the cell widths are reduced so that all the cells are displayed within the div frame. I've played around with this: commenting out css properties to see if...
6
7091
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 browsers and browser versions support this? If the children constructs are not fairly universally supported, then what is a better approach to doing this?
15
2085
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 ); } </script></head> <body onload="ready()"> <script type="text/javascript"> document.open();
4
2471
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 data e.g. with alert(). Is there an easy way to go through the whole table to read the data (each row has an unique ID but I don't know their IDs) or do I need while modifying the table to rememder each row's ID so I can access to data directly...
2
6480
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
2919
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 portion of the table I have another table that specifies "display:none" to hide it. When the page loads, if JavaScript is enabled then it will change to "display:block". However, the problem under Firefox is that the width of
17
5836
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 (requires monospace font): Default: +--------------------+ | H1 H2 H3 | +--------------------+
8
2737
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 addRow = table.insertRow(rowCount); addRow.id = cnt; var addCell = addRow.insertCell(1); addCell.id = cnt;
0
8432
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
8344
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,...
0
8857
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, 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...
0
8764
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
8546
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,...
0
8633
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 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...
0
7367
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1993
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.