Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I am using frames with top and main for the two frames. I use aspx files to display a html table with 88 clickable cells. When the user clicks on the cell, the cell is supposed to send the information to another js function which displays the appropriate report to the main frame but the table appears in the top frame and not the main. I added parent.main.location.document.write(""); for the table code and it did display in the main window but then the cells wouldn't click so it was not usable. What can I do?
*****This is the Table code****
<script type="text/javascript">

function CreateTable(){
	document.write("<table align='center' id='tblMain' border='1' >"); 
    for (var i = 0;i<= 87;i++){
        if (i % 7 == 0){document.write ("<tr>");}
        document.write("<td><a HREF='java<!-- no -->script:DisplayConstellations(" + i + ");'>" + ConName[i] + "</a></td>");                          
        if (i % 7 == 7){document.write ("</tr>"); }
    }
            document.write ("</table>");
}
Posted
Updated 4-Feb-16 5:41am
v3
Comments
Philippe Mori 22-Jan-16 12:37pm    
It is hard to understand. Show us pertinent code.
Philippe Mori 25-Jan-16 18:52pm    
You should update your question with that information. It is hard to follow you as you talk about many unrelated things in a single question. So what is your problem?
- Displaying the 88 cells?
- Updating top window instead of the frame?
- Using the code in that comment from a function?

What does it means to call a table? Do you mean to display a table. It is hard to understand.
If the above code does works rhen what is your problem? You say it works outside a function but the code here and the one in the function does not even look similar?
Member 12001186 22-Jan-16 15:58pm    
A bit more context would help but besides that have you considered overlays?
Dave Kreskowiak 22-Jan-16 19:19pm    
Do NOT post updates to your question as a Solution!

1 solution

Not a complete solution, but there are errors in your code:
C#
var needfooter;	

The variable is not initialized (well it will be because your loop always ends at i == 87). But in that case, the remaining logic is somewhat flawed.

C#
if (i % 8 == 8){ ... }

That condition will never be true since % will returns a value between 0 and 7 inclusively.

Thus in the end, you don't always get the expected output.

By the way, your condition are also broken. If the last i is 87, then it is that last cell in that row and you don't need the footer in that case.

Thus you get a table with unmatched and
. Invalid HTML code might not always display what you want on all browsers.

In your prefered browser, display source code and verify it and fix code accordingly.

By the way, it would be a good idea to write unit test code for that and validate that you get the intended output for any size. You should test edge cases...

Update

If your problem is about where the content is displayed, then remove unrelated stuff from your question (see comment below).

By the way, if you are in a iframe, then all JavaScript code will relate to that iframe. As far as I know, you cannot access the outer frame from code. The only thing you could do is to open a link in top windows. Still your sample code do not show that you have an iframe.
 
Share this answer
 
v2
Comments
Philippe Mori 25-Jan-16 18:30pm    
If you problem is where the windows open, then what is the relation with a table of 88 cells? Do you have a problem displaying a table or displaying something in a new windows? If the later is your problem, then remove everything that is not related to your problem from the question and from sample code. Always use the simplest code that can demonstrate a problem.
Philippe Mori 25-Jan-16 18:40pm    
Don't post long code in comment. It is unreadable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900