HTML - 保留用户填写的字段并在“提交”时显示在下一页上

问题描述 投票:0回答:1

我有一个真正的基本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">

提交此表格后,我希望results.html打印出之前填写的字段。

像这样的东西:

You've entered the following data:
firstname="whatever first name entered"
lastname=
address=

基本上把所有输入id并打印出来作为字符串。

javascript html
1个回答
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();" />
© www.soinside.com 2019 - 2024. All rights reserved.