ASP page with javascript onChange math

molenbeek

New Member
I'm trying to get this field (Order Cost) to update when I change the Quantity to reflect the new cost (Qty * Price)\[code\]<td class="result" align="right">$<Input type="text" maxLength="9" style="text-align:right; width:55px;" align="right" id="OC<%=i %>" value="http://stackoverflow.com/questions/13767679/<%=formatnumber(rstBevInventory("avg_unit_cost"),2)*proposed %>"/></td>\[/code\]It calculates the original total, but when I change the Qty, it calls this Javascript function:\[code\]function reCalcOrder(i){ document.getElementById("OC"+i).value = http://stackoverflow.com/questions/13767679/document.getElementById("P"+i).value * document.getElementById("Q"+i).value; cost = document.getElementById("OC"+i).value; Math.round(cost * 100) / 100; document.getElementById("OC"+i).set("value", "cost"); if (document.getElementById("Q"+i).value < 0){ document.getElementById("Q"+i).value = http://stackoverflow.com/questions/13767679/0; }}\[/code\]I get way too many digits, and it seems like this is because of the way Javascript handles multiplication. Is there a way to have the ASP react when the Qty field is changed? Because ASP seems to do the math without issue.Thanks ahead of time!
 
Back
Top