Why is the data I am printing not in a table format

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-03-26T05:45:28Z Indexed on 2010/03/26 5:53 UTC
Read the original article Hit count: 156

Filed under:
|

Hi This is my program .when i submit the print button i can print the datas but they are not aligned in the table formatthe format in which i need the print to be...How can i print in the correct format

<html>
<head>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js" > </script> 
<script type="text/javascript">

    function PrintElem(elem)
    {   
        //alert('ddd');
        Popup($(elem).text());
    }

    function Popup(data) 
    {
        var mywindow = window.open('', 'mydiv', 'height=400,width=600');
        mywindow.document.write('<html><head><title>my div</title>');
        /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.print();
        return true;
    }

</script>
</head>
<body>

<div id="mydiv">
   <table width="200" border="1">
  <tr>
    <td>sss</td>
    <td>sssss;</td>
    <td>snssbsp;</td>
  </tr>
  <tr>
    <td>ssss;</td>
    <td>sssnbsp;</td>
    <td>snbsp;</td>
  </tr>
  <tr>
    <td>snbsp;</td>
    <td>snbsp;</td>
    <td>snbsp;</td>
  </tr>
</table>

</div>


<input type="button" value="Print Div" onClick="PrintElem('#mydiv')" />

</body>
</html>

© Stack Overflow or respective owner

Related posts about html

Related posts about JavaScript