Search This Blog

Friday, August 19, 2011

Print Using Javascript.

function tablePrint(tblId)
{

var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
display_setting+="scrollbars=yes,width=750, height=600, left=100, top=25";
var lbtnPrint = document.getElementById('ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint');
lbtnPrint.style.display = 'none';
var content_innerhtml = document.getElementById(tblId).innerHTML;
var document_print = window.open("","",display_setting);
//document_print.document.open();
document_print.document.write('<html><head><title>Vendor Bill </title></head>');
document_print.document.write('<body onLoad="self.print();self.close();" >');
document_print.document.write(content_innerhtml);
document_print.document.write('</body> //document_print.print();
document_print.document.close();
lbtnPrint.style.display = 'block';
return false;
}

HTML:
<table id="tbl_display" style="text-align:left;" width="100%" cellpadding="2" cellspacing="2" border="0">
<tr>
<td align="left">
<p> Thank you valuable user for signing up.</p>
<p> We think you’ve made a bold decision, and look forward to a productive meeting.</p>
<p> Please print out a copy of this invitation - it will serve as your boarding pass on this tour. </p>
<p> For additional information, you can email <a href="mailto:someone@someone.com">someone@someone.com</a> or call -
xxx-xxx-xxxx, xxx-xxx-xxx and look for Mr. Someone.</p>
</td>
</tr>
</table>

<input type="ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint" value="Print" onclick="tablePrint('tbl_display');">

No comments:

Post a Comment