简体   繁体   中英

HTML form POST to direct print page

I have the page VIEW-SALE.PHP on this page I have a submit button form to view the invoice in print format, there is the code:

     <span style='display:inline-block'>
    <form name='print' id='print' action='print-invoice.php' 
target='_blank' method='post'>
        <input type='hidden' name='invoice' value='$invoice'>
        <input class='submit-all' type='submit' 
value='Print the invoice' 
onClick='window.print();return false'></form></span>

The code must just open the page PRINT-INVOICE.PHP and print it but when I click it it show the print dialog but of the current page I am VIEW-SALE.PHP so it does not show the PRINT-INVOICE.PHP

How does it can be done?

doesn't post just post data you may need a header redirect the redirect being php code

header("Location: blabla")

I found this you may find it of help redirect after submit

the problem is the onClick='window.print();return false' . The window object is the current window containing the form. You should include an javascript event handler in your PRINT-INVOICE.PHP:

... <body onload="window.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