2 回答
TA贡献1844条经验 获得超8个赞
将您的脚本移到</body>标记之前或下方,form它将起作用。
function sendToQuickPrinter(){
var text =
"<CENTER><MEDIUM2><?php echo $shop_name ?><BR>" +
"<CENTER><?php echo $display_date ?> <?php echo $display_time ?><BR><BR>" +
"Description Price<BR>" +
"<?php $i=0;while($i < $print_count){$i=$i+1; echo $p_name_array[$i].';; ;;'.$transaction_qty_array[$i].' @ '.number_format($p_price_array[$i],2).'<BR>';} ?>" +
"<BR>" +
"<CENTER>Sub-total $<?php echo number_format($subtotal,2) ?><BR>" +
"<CENTER>Tax $<?php echo number_format($subtax,2) ?><BR>" +
"<CENTER>Total $<?php echo number_format($item_total,2) ?><BR>" +
"<BR>" +
"<CENTER>Thank you for shopping with us, we appreciate your business!<BR>" +
"<CENTER><MEDIUM2> Have a great day!<BR>" +
"<BR>" +
"<CUT>" +
"DRAWER";
var textEncoded = encodeURI(text);
window.location.href="quickprinter://"+textEncoded;
document.frm2.submit() // !!!important- I auto submit frm2 below
}
//sendToQuickPrinter();
<form action="cart.php" name="frm2" method="post">
<input type="hidden" name="longitude" id="getlon" />
<input type="hidden" name="latitude" id="getlat" />
<input type="hidden" name="shop_name" value="<?php echo $shop_name ?>" />
</form>
<button id="print" click="sendToQuickPrinter();">Print</button>
TA贡献1816条经验 获得超4个赞
更改document.frm2.submit()与document.forms["frm2"].submit()
function sendToQuickPrinter(){
var text =
"<CENTER><MEDIUM2><?php echo $shop_name ?><BR>" +
"<CENTER><?php echo $display_date ?> <?php echo $display_time ?><BR><BR>" +
"Description Price<BR>" +
"<?php $i=0;while($i < $print_count){$i=$i+1; echo $p_name_array[$i].';; ;;'.$transaction_qty_array[$i].' @ '.number_format($p_price_array[$i],2).'<BR>';} ?>" +
"<BR>" +
"<CENTER>Sub-total $<?php echo number_format($subtotal,2) ?><BR>" +
"<CENTER>Tax $<?php echo number_format($subtax,2) ?><BR>" +
"<CENTER>Total $<?php echo number_format($item_total,2) ?><BR>" +
"<BR>" +
"<CENTER>Thank you for shopping with us, we appreciate your business!<BR>" +
"<CENTER><MEDIUM2> Have a great day!<BR>" +
"<BR>" +
"<CUT>" +
"DRAWER";
var textEncoded = encodeURI(text);
window.location.href="quickprinter://"+textEncoded;
document.forms["frm2"].submit() // !!!important- I auto submit frm2 below
}
添加回答
举报
