garfield11
IS-IT--Management
Hi all,
I have these 2 fields: Quantity(qty) and Total Price(total). I want to make my program to work as like when a user enters a quantity say 50, onchange it will auto compute the total price and also at the same time, if the amount is 4 digit say 1000 i want it to be displayed like this: 1,000.
Below codes work perfectly well,
BUT
when i insert the value into the database, it only insert 1 instead of 1,000....... eh can anyone pls advise.
Thanks and here are my codes:
function computeTotal()
{
var Total;
Total = eval(document.forms[1].unitPrice.value) * eval(document.forms[1].qty.value);
document.forms[1].total.value="";
document.forms[1].total.value=commas(round(Total,2));
}
function commas(num)
{
num=output=num.toString(),l=num.length;
for(var i=l;i>-1;i=i-3)
{
if(i!=0 && i!=l)
{
output=output.substring(0,i)+','+output.substring(i)
}
}
return output;
}
I have these 2 fields: Quantity(qty) and Total Price(total). I want to make my program to work as like when a user enters a quantity say 50, onchange it will auto compute the total price and also at the same time, if the amount is 4 digit say 1000 i want it to be displayed like this: 1,000.
Below codes work perfectly well,
BUT
when i insert the value into the database, it only insert 1 instead of 1,000....... eh can anyone pls advise.
Thanks and here are my codes:
function computeTotal()
{
var Total;
Total = eval(document.forms[1].unitPrice.value) * eval(document.forms[1].qty.value);
document.forms[1].total.value="";
document.forms[1].total.value=commas(round(Total,2));
}
function commas(num)
{
num=output=num.toString(),l=num.length;
for(var i=l;i>-1;i=i-3)
{
if(i!=0 && i!=l)
{
output=output.substring(0,i)+','+output.substring(i)
}
}
return output;
}