I'm trying to update the price of a product if the user selects an optional extra using a dropdown box. It's supposed to update the hidden field as well as the H1 tag which shows the user the new price. It doesn't appear to work.
function xDeckIncreasePrice(price) {
var total = document.getElementById("agreedPrice").value;
var newprice = Number(total) + Number(price);
document.getElementById("mixingDeckTotal").innerHTML = "£" + newprice + "";
document.getElementById("agreedPrice").value = "£" + newprice + "";
}
Here is the HTML:
<select name="size">
<option value="6inch">6 Inch</option>
<option value="footlong" onselect="xDeckIncreasePrice('2.50')">Footlong (+£2.50)</option>
</select>
And here are the elements to be updated:
<h1 style="color:red;" id="mixingDeckTotal">£4.50</h1><p>
<input type="hidden" id="agreedPrice" value="£4.50">