Help Please! Javascript calculator with discounts

I have been pulling my hair out over this for 3 days and I don’t know where to go from here. I have made a calculator that calculates a discount if there is a quantity of 4 or more. However, I need this to calculate over multiple fields and then add all of the prices with the discounts at the end of everything. Any help would be greatly appreciated as I am no javascript guru. Thanks in advance.

<SCRIPT type = "text/JavaScript">
function calcPrice(){
var discount, price, total, savings;
var v = parseInt(document.getElementById("value").value);
var q = parseInt(document.getElementById("quantity").value);
if (q <= 3) discount = 0;
else if (q>=4) {discount = .25}

price = q * v;
savings = q * v * discount;
total = q * v - savings;




  <input type="text" id="quantity" name="first" />
   <input type="hidden" id="value" value="10" name="second" />

<input type="button" onclick="calcPrice()">