thanks for reading this post.
I need help with passing value to next page, but in my case, there is not only one value, but there is also more than one value to choose for and if a user clicks on specific card value then the button with id=save will save the value of the card
(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>
I've tried Sharing a variable between multiple html pages it works for passing only 1 value. In the end, this is what I wanted: user clicks on a specific card -> save the input value of the card -> display the saved value on the next page.
I am still learning about developing a website/coding. Please go easy on me, thank you very much!