This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes Printing with DIV tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Printing with DIV tags" Watch "Printing with DIV tags" New topic
Author

Printing with DIV tags

M Suguna
Ranch Hand

Joined: Jun 07, 2002
Posts: 37
Hi
I have the follwing HTML page.

This code produces a table with 4 rows. Only a part of the table will be visible (say, 2 rows) and the user has to use the scroll bar to view the remaining part of the table.
There is also a Print button in the page which calls window.print()
The problem is, window.print() prints only the visible part of the table (the top 2 rows). I want to print the entire table, when the print button is pressed.
Is there a way to achieve this?


Who says nothing is impossible? I've been doing nothing for years
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
what you will need to do is make the table bigger when the button for print is pushed.... Here is an example I just wrote up. I did not test it in Netscape,,,,only IE
<script>
function ChangeIt(){
wlayer="ViewTable";
if (document.getElementById) {document.getElementById(wlayer).style.height=200;}
else if (document.all) {document.all[wlayer].style.height=200;;}
else if (document.layers) {document.layers[wlayer].height=200;}
}
</script>
<table id="ViewTable" style="height:50" border='1'>
<tr><td><form>
<input type="button" on_click="ChangeIt()" name="butt" value="Make Bigger">
</form></td></tr>
</table>

Remeber to change on_click
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Printing with DIV tags