Print a table using Div

liunx

Guest
Hi<br />
<br />
How can print a table in a web page using div tag???<br />
<br />
shara<!--content-->Do you mean this<br />
<br />
<style><br />
@media print{<br />
.tableContainer{<br />
// specify how you want the table appear in print<br />
}<br />
}<br />
</style><br />
<br />
<div class="tableContainer"><br />
<table><br />
...<br />
</table><br />
</div> <br />
<br />
or this<br />
<br />
<script language="javascript"><br />
function doPrint()<br />
{<br />
document.all("btn1").style.visibility = "hidden";<br />
window.print();<br />
document.all("div1").style.visibility = "visible";<br />
}<br />
</script><br />
<body><br />
<br />
<div id="div1"><table>...</table></div><br />
<br />
<input id="btn1" type="button" value="Print this page" onclick="doPrint()"><br />
<br />
</body><br />
<br />
The second script will print the contents of div ie. the table, but will not print the print button itself.<!--content-->Why use JavaScript to hide the button when CSS can do it?<style type="text/css"><br />
@media print {<br />
.hide {<br />
visiblity: hidden;<br />
}<br />
}<br />
</style>Then for the button:<input type="button" onclick="print();" class="hide" /><!--content-->What to write in Print() function???<br />
<br />
Can you please eaxpalin in details or the exact coding for the same??<br />
<br />
shara<!--content-->
 
Back
Top