我有一个真正的基本html订单表格,要求提供姓名,地址,信用卡信息,账单/运送信息。这是我的html示例。
<fieldset>
<legend>Personal information:</legend>
<form>
<label>
First Name
<input type="text"><br>
</label>
<label>
Last Name:
<input type="text"><br><br/>
</label>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<b>Billing Address</b>
Street Address:
<input type="text" id="address_1">
(City, State, Zip):
<input type="text" id="address_2"> <br/>
<input type="checkbox" id="toshipping_checkbox">
<em>Check this box if Shipping Address and Billing Address are the same.</em> <br/>
<b>Shipping Address</b>
Street Address:
<input type="text" id="shipping_address_1">
(City, State, Zip):
<input type="text" id="shipping_address_2">
&#13;
提交此表单后,我希望results.html
打印出之前填写的字段。
这样的事情:
You've entered the following data:
firstname="whatever first name entered"
lastname=
address=
基本上取所有输入id
&#39;并将其打印为字符串。
答案 0 :(得分:1)
创建用于打印的脚本
<script type="text/javascript">
function PrintDiv() {
$('document').ready(function () {
var divContents = document.getElementById("WOcontainer").innerHTML;
var printWindow = window.open('', '', 'height=800,width=1024');
printWindow.document.write('<html><head><title>Personal Information</title>');
printWindow.document.write('</head><body style=" font-family: Arial; font-size: 10px;" >');
printWindow.document.write(divContents);
printWindow.document.write('</body> </html>');
printWindow.document.close();
printWindow.print();
})
}
</script>
事件处理程序
<input id="Button1" type="button" value="button" onclick="PrintDiv();" />