感谢您阅读这篇文章。
我需要帮助将值传递到下一页,但是在我的情况下,不仅有一个值,而且还有多个值可供选择,如果用户单击特定的卡值,则带有ID的按钮=保存将保存卡的值
(function (global) {
document.getElementById("save").addEventListener("click", function () {
global.localStorage.setItem("mySharedData", document.getElementById("input").value);
}, false);
}(window));
// If user click the button on this card, it will automatically save card1 value to local storage
<div class="card">
<input type="hidden" id="input" value="card1"></input>
<div class="card-body">
This is some text within a card body.
</div>
<button id="save" href="nextpage.php" class="btn">Next</button>
</div>
// If user click the button on this card, it will automatically save card2 value to local storage
<div class="card">
<input type="hidden" id="input" value="card2"></input>
<div class="card-body">
This is some text within a card body.
</div>
<button id="save" href="nextpage.php" class="btn">Next</button>
</div>
我尝试过Sharing a variable between multiple html pages,它只能传递1个值。最后,这就是我想要的:用户单击特定的卡->保存卡的输入值->在下一页上显示保存的值。
我仍在学习有关开发网站/编码的知识。请放心,我非常感谢!