looks like you added this line to set the product stock
if(priceInfo[2] !="") { document.getElementById("productStock").innerHTML = priceInfo[2]; }
That would work if you had a span with the ID productStock
<span id="productStock"></span>
using the hidden element:
<input type="hidden" name="remaingQuantity" id="remaingQuantity" value="0" />
to set it's value, use:
if(priceInfo[2] !="") { document.getElementById("remaingQuantity").value = priceInfo[2]; }
in the calcualtion:
abs([Quantity] > [AvailableQuantity])?[Quantity] = [AvailableQuantity]:"
abs() is a ternary expresion. Basicly it is a short hand if statement, in the form of:
abs(Question)?true:false
so, the question is:
[Quantity] > [AvailableQuantity] <- is the quatity greater than the available quatity?
if true:
[Quantity] = [AvailableQuantity] <- set Quantity to be the same as available quantity
if false:
'' <- do nothing.