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:
[CODE=javascript]function copyTable(table Number) {
// Get the table frame
var tableIFrame = eval("generated Frame" + tableNumber);
// Get the table
var tableOnPage = tableIFrame.doc ument.getElemen tById("table" +
tableNumber);
// Clone this table, so that we can remove the links without changing
the page
var myTable = tableOnPage.clo neNode(true);
var hiddenTableOnPa ge = document.getEle mentById
("tableIDHidden Field" + tableNumber);
var myHiddenTable = hiddenTableOnPa ge.cloneNode(tr ue);
var myTableHTML = "";
// Run through stripping out links
for (var i=0;i < myTable.documen t.all.length; i++) {
if (myTable.docume nt.all(i).tagNa me == 'A') {
myTable.documen t.all(i).remove Node(false);
}
}
// Get the HTML for the table
for (var i=0;i < myTable.documen t.all.length; i++) {
if (myTable.docume nt.all(i).tagNa me == 'TH' ||
myTable.documen t.all(i).tagNam e == 'TD') {
myTableHTML += myTable.documen t.all
(i).innerText + '\t';
}
if (myTable.docume nt.all(i).tagNa me == 'TR') {
if (myTableHTML.le ngth > 1)
myTableHTML += '\n';
}
}
// Run through stripping out links
for (var i=0;i < myHiddenTable.d ocument.all.len gth; i++) {
if (myHiddenTable. document.all(i) .tagName == 'A') {
myHiddenTable.d ocument.all(i). removeNode(fals e);
}
}
// Get the HTML for the hidden table
for (var i=0;i < myHiddenTable.d ocument.all.len gth; i++) {
if (myHiddenTable. document.all(i) .tagName == 'TH' ||
myHiddenTable.d ocument.all(i). tagName == 'TD') {
myTableHTML += myHiddenTable.d ocument.all
(i).innerText + '\t';
}
if (myHiddenTable. document.all(i) .tagName == 'TR') {
if (myTableHTML.le ngth > 1)
myTableHTML += '\n';
}
}
// Put the HTML into the clipboard.
window.clipboar dData.setData(' Text', myTableHTML);
}
[/CODE]
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
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:
[CODE=javascript]function copyTable(table Number) {
// Get the table frame
var tableIFrame = eval("generated Frame" + tableNumber);
// Get the table
var tableOnPage = tableIFrame.doc ument.getElemen tById("table" +
tableNumber);
// Clone this table, so that we can remove the links without changing
the page
var myTable = tableOnPage.clo neNode(true);
var hiddenTableOnPa ge = document.getEle mentById
("tableIDHidden Field" + tableNumber);
var myHiddenTable = hiddenTableOnPa ge.cloneNode(tr ue);
var myTableHTML = "";
// Run through stripping out links
for (var i=0;i < myTable.documen t.all.length; i++) {
if (myTable.docume nt.all(i).tagNa me == 'A') {
myTable.documen t.all(i).remove Node(false);
}
}
// Get the HTML for the table
for (var i=0;i < myTable.documen t.all.length; i++) {
if (myTable.docume nt.all(i).tagNa me == 'TH' ||
myTable.documen t.all(i).tagNam e == 'TD') {
myTableHTML += myTable.documen t.all
(i).innerText + '\t';
}
if (myTable.docume nt.all(i).tagNa me == 'TR') {
if (myTableHTML.le ngth > 1)
myTableHTML += '\n';
}
}
// Run through stripping out links
for (var i=0;i < myHiddenTable.d ocument.all.len gth; i++) {
if (myHiddenTable. document.all(i) .tagName == 'A') {
myHiddenTable.d ocument.all(i). removeNode(fals e);
}
}
// Get the HTML for the hidden table
for (var i=0;i < myHiddenTable.d ocument.all.len gth; i++) {
if (myHiddenTable. document.all(i) .tagName == 'TH' ||
myHiddenTable.d ocument.all(i). tagName == 'TD') {
myTableHTML += myHiddenTable.d ocument.all
(i).innerText + '\t';
}
if (myHiddenTable. document.all(i) .tagName == 'TR') {
if (myTableHTML.le ngth > 1)
myTableHTML += '\n';
}
}
// Put the HTML into the clipboard.
window.clipboar dData.setData(' Text', myTableHTML);
}
[/CODE]
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
Comment