Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
137
rated 0 times [  144] [ 7]  / answers: 1 / hits: 59946  / 15 Years ago, wed, may 20, 2009, 12:00:00

I am looking for a way to add parameters on a print function, because I have to print only the table and when I alert the table it shows me the correct value but when I'm printing it prints the entire page.



My code is



aa = document.getElementById('tablename').innerHTML


If I alert(aa) it gives me the write value
then I print(aa) it give me the entire page.
so I tried print(aa) and aa.print and it doesn't work.



Does anyone know the solution for this?


More From » javascript

 Answers
25

Print stylesheets are nice, but you can still accomplish this in Javascript. Just pass your value to be printed to the following function...



function printIt(printThis) {
var win = window.open();
self.focus();
win.document.open();
win.document.write('<'+'html'+'><'+'body'+'>');
win.document.write(printThis);
win.document.write('<'+'/body'+'><'+'/html'+'>');
win.document.close();
win.print();
win.close();
}

[#99495] Friday, May 15, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nathanaelzechariahl

Total Points: 745
Total Questions: 86
Total Answers: 103

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
;