PDA

View Full Version : How can i Print a selected table



ScorpionZ
Jun 6th, 2008, 07:54 AM
Hi
can any one have an idea How should I print a selected table, with different ID, Like I have 2 different tables on Page, with 2 buttons
Print View and
Print It
If pressing "Print View" ---------- I will see table of Id: id="table_1" not id="table_2"
and same in Printing only table of ID: id="table_1"

I create function but stuck to make it

here they are on a page:

<style type="text/css">
<!--
.style3 {color: #FFFFFF; font-weight: bold; }
-->
</style>
<script>
function printme()
{
}

function printpreview()
{
}


</script>

<table id="table_1" width="73%" height="77" border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#333366" align="center">
<td><a href="#" style="color:#FFFF99;font-weight:bold;">Insert</a></td>
</tr>
<tr bgcolor="#333366" align="center">
<td><a href="#" style="color:#FFFF99;font-weight:bold;">Update</a></td>
</tr>
<tr bgcolor="#333366" align="center">
<td ><a href="#" style="color:#FFFF99;font-weight:bold;">Delete</a></td>
</tr>
</table>

<table id="table_2" width="76%" height="112" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="19" bgcolor="#333366" align="center"><a href="#" style="color:#FFFF99;font-weight:bold;">Poll</a></td>
</tr>
<tr bgcolor="#999999" >
<td>&nbsp;</td>
</tr>
</table>

<input type="button" name="print" id="print" value="Print It" onclick="printme()" />
<input type="button" name="print" id="print" value="Print View" onclick="printpreview()" />


any Response will be appreciated
Waiting for the best Reply

Regards
The Scorp

marcha
Jun 6th, 2008, 10:17 AM
Hi,

You should try to create a stylesheet for media print with

table { display: none; } /* disable any tables */

And when you click on the print button for a specific table
first modify the inline style to display: table, like this:

document.getElementById('table_id').style.display = 'table';

this should override the setting in the print stylesheet.

hope this will work :-)

ScorpionZ
Jun 7th, 2008, 07:36 PM
Thanks marcha for Response back to my thread,
But I didnt Understand your exact point, What you are Trying to refer?

Reply me

Thanks and Regards
ScorpionZ

marcha
Jun 9th, 2008, 01:57 PM
Hi ScorpionZ,

Can you explain me what is not clear in my post, css for media print ?
javascript code ? both ?

regards,

ScorpionZ
Jun 17th, 2008, 03:54 AM
Well Thanks marcha for taking Interest
But i have already define it in my first Post.... that what am i looking for.....