I want to change the amount shown on the html page after user clicks on them. There are 2 buttons and upon clicking each button, it should direct them to a new html and the amount should change accordingly. I know this isn't really the method to do it but I am unsure how else can I do it. Currently, I am only able to append all the amount.
<button onclick="myFunction1()" type="submit" id="one">BUY</button>
<button onclick="myFunction2()" type="submit" id="two">BUY</button>
function myFunction1() {
window.location='pay.html';
};
function myFunction2() {
window.location = 'pay.html';
};
<span class="title" id="total"></span>
<span class="title" id="total2"></span>
(function () {
"use strict";
$().ready(function () {
})
myFunction1()
function myFunction1() {
var totalamt = '$100';
$('#total').html("<span style='float:right'>" + "Total:" +
totalamt + "</span>");
}
})();
(function () {
"use strict";
$().ready(function () {
})
myFunction2()
function myFunction2() {
var totalamt2 = '$300';
$('#total2').html("<span>" + "Total:" + totalamt2 +
"</span>");
}
})();
Want to achieve the results of: e.g. by clicking the first button, redirects user to pay.html and show $100. By clicking the second button, redirects to the same html(pay.html), show $300. Please help thanks a lot.