473,396 Members | 2,129 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.

insert html table in iframe

I have been trying for many years to insert my html table into the lower main iframe with no success. Here is my javascript code:

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:Display_Table()" target="main">Constellations</a>
  2.  
  3. <script type="text/javascript">
  4. function Display_Table(){
  5. var numOfCells = 88; 
  6. var columns = 8, rows = Math.ceil(numOfCells / columns), content = "", count = 0;
  7. content = "<table border='1' cellspacing='1' cellpadding='5'>";
  8. for (r = 0; r < rows; r++) {
  9.    content += "<tr>";
  10.    for (c = 0; c < columns; c++) {
  11.       content += "<td><a HREF='javascript:DisplayConstellations(" + count + ");'>" + ConName[count] + "</a></td>";
  12.       if (count == numOfCells)break;  // here is check if number of cells equal Number of Pictures to stop
  13.       count++;
  14.    }
  15.    content += "</tr>";
  16. }
  17. content += "</table>";
  18. document.body.innerHTML = content; 
  19. }
  20. </script>
Jul 11 '19 #1

✓ answered by gits

in the code you call a method: DisplayConstellations which is assigned to an anchor tag somehow instead of an onclick-event. probably you need to check that function's code.

11 3279
gits
5,390 Expert Mod 4TB
what happens at the moment? the html you create in the function is replacing the content of your window - since you get a reference to the window's document and tell the code to do so with:

Expand|Select|Wrap|Line Numbers
  1. document.body.innerHTML = content;
you cannot target javascript code with a links target-attribute - javascript would need to reference the correct window and then the document in that window. you can use the frames property of your top.window for example to achieve that.
Jul 12 '19 #2
I have 2 iframes one for the horizontal menu and the other is underneath the menu iframe to recieve whatever is selected from the menu. I just need some sample code to insert the 88 cells into the iframe so the User can click on a cell and let the corresponding listing appear where the table was. I used to do this before html 5 came out but now I have no idea as to what code I need to use. I am an 81 year old retired vb6 programmer and I am out of touch with the latest methods to use iframes. Thank you for your reply. John
Jul 13 '19 #3
gits
5,390 Expert Mod 4TB
there is not something about latest methods to use frames - except may be to not use any frames at all - everything is usually achieved with css today. for a simple example on how to access an iframe you can start from here:

https://www.w3schools.com/jsref/prop...ntdocument.asp
Jul 14 '19 #4
I tried the w3schools.com but no one seems to understand that all I want to do is insert my html5 table into iframe and keep the iframe away from the top iframe.
Jul 15 '19 #5
gits
5,390 Expert Mod 4TB
in the example there the background color of the iframe is set - you can use the same method to reference the iframe's document to set any other content there
Jul 16 '19 #6
I managed to get the table into the iframe but the table erased the menu. when I clicked the cell to start a listing the list went to another page.
Jul 16 '19 #7
gits
5,390 Expert Mod 4TB
in the code you call a method: DisplayConstellations which is assigned to an anchor tag somehow instead of an onclick-event. probably you need to check that function's code.
Jul 16 '19 #8
I have success with one of the functions but the other
won't cooperate. This is the one that won't go into the iframe
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.      function DisplayConstellations(selection){
  3.        var Z = trim(Left(ZoneOrder[selection],2));
  4.        var Order = trim(Right(ZoneOrder[selection],2));    
  5.        document.body.innerHTML = "http://localhost/PSC/Documents/Zonesjs/Zone" + Z + ".html?Order=" + Order;
  6. }
  7.  
  8.     function Display_Table(){
  9.       var numOfCells = 88; 
  10.       var columns = 8, rows = Math.ceil(numOfCells / columns), 
  11.     content = "", count = 0;
  12.     content = "<table border='1' cellspacing='1' cellpadding='5'>";
  13.     for (r = 0; r < rows; r++) {
  14.       content += "<tr>";
  15.       for (c = 0; c < columns; c++) {
  16.       content += "<td><a HREF='javascript:DisplayConstellations(" + count + ");'>" + ConName[count] + "</a></td>";
  17.       if (count == numOfCells)break;  // here is check if number of cells equal Number of Pictures to stop
  18.       count++;
  19.       }
  20.       content += "</tr>";
  21.       }
  22.       content += "</table>";
  23.       john.document.body.innerHTML = content; 
  24.       }
Jul 31 '19 #9
gits
5,390 Expert Mod 4TB
in your line 5 you have:

Expand|Select|Wrap|Line Numbers
  1. document.body.innerHTML = something
this will overwrite the content (=html) of your current scoped window's document.
Aug 1 '19 #10
I see that you don't understand what I am looking for. All I wanted was to display a html document in the iframe once a cell was clicked on and the document would replace the table in the iframe.
Aug 22 '19 #11
gits
5,390 Expert Mod 4TB
linking the other related thread here:

https://bytes.com/topic/javascript/a...l-display-file

solution to the issue is in post #20.

The problem isn't that readers dont understand what the OP wanted - the problem is that there is a bunch of messy code that people have to dig through to finally find where the problem is. The shown solution there would solve the requirement but not the issue with the code that is 'shooting yourself in the foot'. Using proper CSS and JavaScript here would make the entire thing much more understandable and maintainable.
Aug 23 '19 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: | last post by:
Hello, here is the code: <? $a=array(1,2,3,4,5,6,7,8,9,10); $b=array(1,3,5,7,9); $c=array(1,1,2,2,3,3); $d=array_count_values($b); $e=array_count_values($c);
11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
1
by: Karim | last post by:
I have a form built into an html table. One of the form elements is an asp.net dropdownlist. For some options in the listbox, I want to insert a new table row under the listbox to grab some more...
1
by: ven | last post by:
hello i have problem with response.redirect method, namely i have default page home.aspx where is html table : <%@ Page Language="VB" %> <script runat="server"> ' Insert page code here '
3
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
1
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
5
by: Andrew | last post by:
Hi, friends, In ASP, we use obj = CreateObject("com.dll") obj.GetHTMLText(inVal, outHTMLTxt1, outHTMLTxt2) to get different HTML strings based on input values. Then, we insert them into...
2
by: Gordon | last post by:
VB.Net 2003 Standard - Creating ASP.Net Web Application In design mode, I can drag a html table from the toolbox to the work area but I can't seem to be able to select individual cells or...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
3
Soniad
by: Soniad | last post by:
Hello, I want a complete table structure assign to a variable and then insert this table structure in one of column of sql table. the problem i am facing is vbscript is not interpreting html...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
isladogs
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...

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.