【问题标题】:Input-store-store-output输入-存储-存储-输出
【发布时间】:2013-03-06 22:08:15
【问题描述】:

我无法获得在另一页上存储一些值并将其输出到下一页的功能。 例如,我的 dog.html 和 cat.html 分别有一个提交按钮。我想获取 dog.html 和 cat.html 的输入并在 pay.html 上输出值(单击 cat.html 中的提交按钮后

我在 pay4.html 中有这段代码,我可以从上一页获取值。

function getParams(){
    var idx = document.URL.indexOf('?');
    var params = new Array();
    if (idx != -1) {
        var pairs = document.URL.substring(idx+1,
                document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++){
            nameVal = pairs[i].split('=');
            params[nameVal[0]] = nameVal[1];
        }
    }
    return params;
}
params = getParams();
Name = unescape(params["Name"]);
Address = unescape(params["Address"]);
ContactNo = unescape(params["ContactNo"]);
Email = unescape(params["Email"]);
document.write("Name: " + Name + "<br>");
document.write("Address: " + Address + "<br>");
document.write("Contact number: " + ContactNo + "<br>");
document.write("E-mail: " + Email + "<br>");

在输出我输入的所有值之前,我需要在某些页面中再次输入。

<form name="info" action="pay1.html" type=GET>
<form name="info" action="pay2.html" type=GET>
<form name="info" action="pay3.html" type=GET>
<form name="info" action="pay4.html" type=GET>

【问题讨论】:

    标签: javascript html input output


    【解决方案1】:

    尝试使用 cookie 跨多个页面传输您的数据(假设它们位于同一域中)。 如果它在服务器上运行,则可以使用会话。

    阅读更多https://developer.mozilla.org/en-US/docs/DOM/document.cookie

    【讨论】:

      猜你喜欢
      • 2020-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-08
      相关资源
      最近更新 更多