Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

JavaScript: Print ONLY the Table


Leb i Sol

This topic is 7864 days old. Please don't post here. Open a new topic instead.

Recommended Posts

hello People!

I found this script VERY useful when one desires to print ony a specific table on the page. Here is the script:

 



<html>



<head>



<title>PRINT</title>



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



</head>



<body>



<table width="711" height="162" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" id="TABLE_NAME_OF_TABLE_THAT_YOU_WANT_TO_PRINT">



  <tr>



    <td align="center">OUTPUT HERE</td>



  </tr>



</table>



<table width="712" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" id="PRINT">



  <tr> 



    <td height="30" align="center"><a href="#"	onClick="w=window.open('','newwin'); w.document.write('<bo'+'dy onLoad='window.print()'>'+



				'<table>'+document.getElementById('TABLE_NAME_OF_TABLE_THAT_YOU_WANT_TO_PRINT').outerHTML+'</table></bo'+'dy>');



				w.document.close(); return false">



				<font size="4" face="Verdana, Arial, Helvetica, sans-serif">.: PRINT .</font></a> 



    </td>



  </tr>



</table>



</body>



</html>



 

Link to comment
Share on other sites

No problem...this was a script I found the then edited to fit the needs of my printing.I thought some one might use it...this is what this forum is all about,right!?

side note:

If you use some JS inside the 'TABLE_NAME_OF_TABLE_THAT_YOU_WANT_TO_PRINT'table then edit/remove bold parts of the code.....the bold (<table></table>)part of the code:

------------

<table>'+document.getElementById('TABLE_NAME_OF_TABLE_THAT_YOU_WANT_TO_PRINT').outerHTML+'</table>

-----------

to strip the 'TABLE_NAME_OF_TABLE_THAT_YOU_WANT_TO_PRINT'table from the borders and html decorations and such use

.innerHTML in the code above!

happy printing laugh.gif

Link to comment
Share on other sites

This topic is 7864 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.