I'm updating the amount of a PayPal button with a variable amount. I'm getting the amount like this:
<input type="hidden" name="amount" value="" />
var amount = document.querySelector('.total-box > span').innerText;
var hidden = document.querySelector("input[name='amount']");
hidden.value = amount;
console.log(hidden.value);
That amount updates .total-box > span
when paypal fees are added to the total.
Therfore I need the console log(hidden.value)
to update as well so it updates the PayPal amount field. Currently console log(hidden.value)
is only running one time on page load, and doesn't update or get passed to PayPal.
Here is a JSFiddle to better explain what is going on. Any help would be appreciated.