473,382 Members | 1,409 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,382 software developers and data experts.

how to copy the content of table and the content on hidden table in a page.

Hi,

Please help me to solve this one. I have page with tables (including hidden tables), my problem is how can I copy both the content of the table.
Here is my code snippets:

Expand|Select|Wrap|Line Numbers
  1. function copyTable(tableNumber) {
  2.  
  3.     // Get the table frame
  4.     var tableIFrame = eval("generatedFrame" + tableNumber);    
  5.     // Get the table
  6.     var tableOnPage = tableIFrame.document.getElementById("table" +  
  7.                                            tableNumber);
  8.     // Clone this table, so that we can remove the links without changing
  9.                    the page
  10.     var myTable = tableOnPage.cloneNode(true);
  11.  
  12.     var hiddenTableOnPage = document.getElementById
  13.                                                       ("tableIDHiddenField" + tableNumber);
  14.  
  15.     var myHiddenTable = hiddenTableOnPage.cloneNode(true);
  16.  
  17.     var myTableHTML = "";
  18.  
  19.     // Run through stripping out links
  20.     for (var i=0;i < myTable.document.all.length; i++) {
  21.         if (myTable.document.all(i).tagName == 'A') {
  22.             myTable.document.all(i).removeNode(false);
  23.         }    
  24.  
  25.     }
  26.  
  27.     // Get the HTML for the table
  28.     for (var i=0;i < myTable.document.all.length; i++) {        
  29.         if (myTable.document.all(i).tagName == 'TH' ||
  30.             myTable.document.all(i).tagName == 'TD') {
  31.             myTableHTML += myTable.document.all
  32.                                                  (i).innerText + '\t';
  33.         }
  34.         if (myTable.document.all(i).tagName == 'TR') {
  35.             if (myTableHTML.length > 1) 
  36.                 myTableHTML += '\n';
  37.         }
  38.     }
  39.  
  40.                 // Run through stripping out links
  41.     for (var i=0;i < myHiddenTable.document.all.length; i++) {
  42.         if (myHiddenTable.document.all(i).tagName == 'A') {
  43.         myHiddenTable.document.all(i).removeNode(false);
  44.         }
  45.  
  46.     }
  47.  
  48.                 // Get the HTML for the hidden table
  49.     for (var i=0;i < myHiddenTable.document.all.length; i++) {                    
  50.         if (myHiddenTable.document.all(i).tagName == 'TH' ||
  51.         myHiddenTable.document.all(i).tagName == 'TD') {
  52.         myTableHTML += myHiddenTable.document.all
  53.                                 (i).innerText + '\t';
  54.         }
  55.         if (myHiddenTable.document.all(i).tagName == 'TR') {
  56.             if (myTableHTML.length > 1) 
  57.                 myTableHTML += '\n';
  58.         }        
  59.     }
  60.  
  61.     // Put the HTML into the clipboard.
  62.     window.clipboardData.setData('Text', myTableHTML);
  63. }
  64.  
  65.  
I tried to run this code, but it seems not working in hidden table..I can't copy the content in hidden table but if I delete the code for hidden table, it works fine.

I want to copy the content of this both table. Ho can i do that?
Please help me out this...I will greatly appreciate ur help..

Regards,
froi
Apr 11 '08 #1
2 1525
acoder
16,027 Expert Mod 8TB
Instead of table.document.all use table.getElementsByTagName("th") (tr, etc.) to get the tags or you could even use innerHTML.
Apr 13 '08 #2
Instead of table.document.all use table.getElementsByTagName("th") (tr, etc.) to get the tags or you could even use innerHTML.

Hi,

I want to insert a code for hiddenTable inside this for loop:

Expand|Select|Wrap|Line Numbers
  1. for (var i=0;i < myTable.document.all.length; i++) {        
  2.         if (myTable.document.all(i).tagName == 'TH' ||
  3.             myTable.document.all(i).tagName == 'TD') {
  4.             myTableHTML += myTable.document.all
  5.                                                  (i).innerText + '\t';
  6.         }
  7.         if (myTable.document.all(i).tagName == 'TR') {
  8.             if (myTableHTML.length > 1) 
  9.                 myTableHTML += '\n';
  10.         }
  11.     }
  12.  
  13.  
how can I do that? or what and where I put some code for hiddenTable?
Would you please give me an example code or logic for hiddenTable.

Thanks for your help..
Apr 14 '08 #3

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

Similar topics

2
by: Liming | last post by:
hello, I have the follwoing code <div id="detailtable" style="visibility:hidden"> <table id="detailtablehidden" width="100%" border="0"> .... </table> </div>
1
by: cotton_gear | last post by:
Hello, Fiest of all let me thank this group for so quick in responding to any postings. I am using a javascript based utility from a site to sort the columns of the table. But, for some strange...
2
by: Advo | last post by:
Basically, ive got information in a table for the layout purposes, as its text for a questionnaire What i Need, is for instance when the user click a radio button, that information can be...
4
by: Mori | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. This code works if no masterpage is involved. ...
1
by: darwin2kx | last post by:
I have a problem that I've been tracking down for a while now. I'm working on a script that dynamically adds blocks for data entry to a page. This script works on one page but not another. For some...
3
by: autospanker | last post by:
Ladies and Gentleman, I have been having this problem that has been driving me insane. I have a website that when viewed in Firefox first, the content in the body area is pushed down. Then when...
3
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
2
by: Spizzat2 | last post by:
I've got a web page with some hidden elements that can be shown through various methods. What I'd like is, when the user tries to copy the visible stuff on the page, it doesn't copy the hidden...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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...

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.