print the current record

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SAN CAZIANO

    print the current record

    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


  • Grant Wagner

    #2
    Re: print the current record

    SAN CAZIANO wrote:
    [color=blue]
    > 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[/color]

    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.getEl ementById &&
    (row = document.getEle mentById('row' + n) &&
    row.style &&
    typeof row.style.displ ay == 'string') {

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

    <tr id="rowXX">
    <td><button onclick="printR ow(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 <gwagner@agrico reunited.com>
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    Working...