简体   繁体   中英

Print the popup using print function of javascript

i have a modal popup "gatepass". when i click on generate , it generates this gatepass. In this gatepass i have two buttons close and print . when i click on print button, i want the gatepass to print and not the background. please guide me , how can i do it?

<html>
<head>
 <script src="js/calculateamt.js" type="text/javascript"></script>
      <link href="CSS/popup.css" rel="stylesheet" type="text/css">

</head>
<body>
   <fieldset id="gatepass" class="popup">
    <p align="center"><span style="size: 40px; font-size: 24px; alignment-adjust:middle">CASH RECIEPT</span></p>
    <table width="453" border="0" align="center" cellpadding="20px">
            <tr>
                <td width="188" height="51">RECIEPT NO : 
                    <label id="recno"><%=recieptno%></label></td>
                <td width="179">DATE : <label id="date"><%=date%></label></td>
            </tr>
            <tr>
                <td height="57">NAME : <label id="name" > <%=firstname%> <%=lastname%></label></td>
                <td>VILLAGE : <label id="village"> <%=vill%></label></td>
            </tr>
        </table>

        <p>&nbsp;</p>
        <table width="697" height="52" border="0" align="center" cellpadding="20px">
            <tr>
                <td width="205">AGREEMENT NO : <label id="agrno"> <%=agreno%></label> </td>
                <td width="149">LOT NO : <label id="lotno"><%=agreno%>/<%=bag%></label></td>
                <td width="151">BAGS : <label id="bags" ><%=bag%></label></td>
                <td width="174"> VEHICLE NO : <label id="vehicle"></label></td>
            </tr>
        </table>
        <p>&nbsp;</p>
        <table width="200" height="47" border="0" align="center" cellpadding="20px">
            <tr>
                <td> TOTAL AMOUNT : 
                    <label onloadstart="javascript:totalamt()" id="Totalamt" name ="total"></label></td>

            </tr>
        </table>
        <p align="center">
        <p align="center">
            <input type="button" name="Print" id="Print" value="PRINT" onClick="window.focus();window.print();">
            <input type="button" name="close" id="close" value="CLOSE" onClick = "closePopup();"  /> 

        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>

    </fieldset>

</body>
</html>

I suggest you reseach up on print style sheets

http://www.webdesignerdepot.com/2010/01/10-tips-for-better-print-style-sheets/

<link rel="stylesheet" type="text/css" href="print.css" media="print" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM