【问题标题】:Change value with button on another page使用另一页上的按钮更改值
【发布时间】:2015-01-24 14:33:39
【问题描述】:

我正在使用 html/css/js 制作日历。 我有一个 index.html :

<html>
<head>
    <title>App calendario</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="myfunc.js"></script>
</head>
<body>
<form> 
<button class="button-customize" onclick="MyFunction(4)" type="button">4 - 10</button> 
</form>
</body>

js是:

function MyFunction(x) {
window.open("settimana.html","_self");
document.getElementById("Giorno_1").innerHTML = x;}

另一个页面 settimana.html 是:

<html>
<head>
    <title>Settimana</title>
    <link rel="stylesheet" href="./style.css" type="text/css" />
    <script src="myfunc.js"></script>
</head>
<body>
<form action="#"> 
 <button class="button-customize" type="submit" id="Giorno_1" name="Giorno_1">Giorno 1</button> 
 </form>
 </body>
 </html>

问题在于页面 settimana.html 中按钮的值没有改变。为什么?请帮帮我。

【问题讨论】:

  • settimana 和 index 都使用同一个脚本文件,但这并不意味着它们共享同一个脚本文件。它们在内存中都有一个副本,因此其中一个的更改不会影响另一个。您需要在加载之前传递所需的任何数据。

标签: javascript html function button


【解决方案1】:

您需要说明您的脚本应该将数据发送到服务器的位置。所以你需要类似的东西

<from method="POST" action="target.php">......</form>

iMo 您需要一个服务器脚本,该脚本通过“$_POST”全局变量(在 PHP 中)使用您的公式数据。我想使用纯 html,您可以发送包含表单数据的电子邮件。

http://php.net/manual/de/reserved.variables.post.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多