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