0

I have a JSP page which contains a Form and also a Table .When i click on print button only table should be get printed .please help me out.

user3331920
  • 41
  • 1
  • 3
  • 10
  • You want the print button in your browser not to print the whole page you see? Does not sound like the normal behavior. – Thorbjørn Ravn Andersen Mar 13 '14 at 17:33
  • my web page contains a table .. i want to print only table from web page when i click on Print button – user3331920 Mar 13 '14 at 17:35
  • This can be achieved through CSS: http://stackoverflow.com/q/401623/1065197 http://stackoverflow.com/q/355313/1065197 http://stackoverflow.com/q/19533186/1065197 http://stackoverflow.com/q/9840004/1065197 and on and on... – Luiggi Mendoza Mar 13 '14 at 17:36
  • and in [here](http://stackoverflow.com/questions/16382108/hide-form-controls-when-printing-an-html-page-with-css) – Cahit Gungor Mar 13 '14 at 17:43
  • CSS method depends on browser support for proper CSS versions, opening the table content in another tab and initiating print will be more feasible. – harshal Mar 13 '14 at 17:53
  • how to open in a new tab and print ... please send me link. – user3331920 Mar 13 '14 at 17:56

2 Answers2

1

One of the way to achieve this to open another tab which will only contain that table you want to print. Then on document.load of that pop-up call the JavaScript function window.print()

This will open print window from there you can print the contents of pop-up.

anuragal
  • 3,024
  • 19
  • 27
0

You can use the window event of javascript just call this event when you press the button

window.print();
iamsuman
  • 1,413
  • 19
  • 32