html - Trying to calculate the total price of items taking into account the quantity selected Javascript -
this first time posting on site. have webpage outlines 1 of products intent sell
here dilemma. have code asks user press + , - buttons quantity of item want. trying work out if user presses + or - number of times need able to take account number of clicks , calculate total price order on separate line. im new javascript appreciated thanks
<form> <br> item price: $463.50 <br> please select quantity <input type='button' name='subtract' onclick='javascript: document.getelementbyid("qty").value--;' value='-'/> <input type='button' name='add' onclick='javascript: document.getelementbyid("qty").value++;' value='+'/> <input type='text' name='qty' id='qty' /> </form>
<form> <br> item price: $<span id='price'>463.50</span> var unitprice = (document.getelementbyid('price').innertext || document.getelementbyid('price').textcontent); var price = parsefloat(unitprice); var count = parseint(document.getelementbyid("qty").value, 10) var total = price * count; alert(total); // or whatever want