Click to See Complete Forum and Search --> : Print a table using Div


shanuragu
11-26-2003, 06:36 AM
Hi

How can print a table in a web page using div tag???

shara

lillu
11-26-2003, 09:28 AM
Do you mean this

<style>
@media print{
.tableContainer{
// specify how you want the table appear in print
}
}
</style>

<div class="tableContainer">
<table>
...
</table>
</div>

or this

<script language="javascript">
function doPrint()
{
document.all("btn1").style.visibility = "hidden";
window.print();
document.all("div1").style.visibility = "visible";
}
</script>
<body>

<div id="div1"><table>...</table></div>

<input id="btn1" type="button" value="Print this page" onclick="doPrint()">

</body>

The second script will print the contents of div ie. the table, but will not print the print button itself.

fredmv
11-28-2003, 01:44 AM
Why use JavaScript to hide the button when CSS can do it?<style type="text/css">
@media print {
.hide {
visiblity: hidden;
}
}
</style>Then for the button:<input type="button" onclick="print();" class="hide" />

shanuragu
11-28-2003, 02:53 AM
What to write in Print() function???

Can you please eaxpalin in details or the exact coding for the same??

shara