By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

print the current record

P: n/a
I have to insert a button in the left of all record in a table to print the
current record, simply create a table and print it in the printer.

anyone have an idea or there is a printer/report utility
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
SAN CAZIANO wrote:
I have to insert a button in the left of all record in a table to print the
current record, simply create a table and print it in the printer.

anyone have an idea or there is a printer/report utility


To print only the current record, you could set all rows to not print using
CSS, then "turn that row on" and call window.print(), it's not elegant, but it
would probably work.

<style type="text/css">
@media print {
tr {
display: none;
}
}
</style>
<script type="text/javascript">
function printRow(n) {
var row;
if (document.getElementById &&
(row = document.getElementById('row' + n) &&
row.style &&
typeof row.style.display == 'string') {

row.style.display = '';
window.focus();
window.print();
row.style.display = 'none';
}
}
</script>

<tr id="rowXX">
<td><button onclick="printRow(XX);"></button></td>
<td>...</td>
</tr>

Note for this to work, the browser will need to support getElementById, will
need to block (ie - halt the script until the print dialog disappears) on the
window.print() call (some browsers don't), and everything you don't want
printed will have to also be set to display: none when the page loads.

The other alternative is to open a new window, write the row you want to that
window and print it.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.