I am replicating a grocery store webpage for a course project and would like to know how to keep the value in the quantity box even after the webpage has been refreshed.
<button type="button" id="subtract" onclick="decrease()">-</button>
<input class="quantity-box" type="text" id="text" value="0">
<button type="button" id="add" onclick="increase()">+</button>
<script>
function decrease(){
var textBox = document.getElementById("text");
if (textBox.value>0){
textBox.value--;
}
}
function increase(){
var a = 1;
var textBox = document.getElementById("text");
textBox.value++;
}
</script>
Note: I am able to use AJAX, but I am not familiar with this so if it is included in the solution a brief explanation would suffice. HTML/JAVASCRIPT/CSS/AJAX