print the current record

S

SAN CAZIANO

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
 
G

Grant Wagner

SAN said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top