PDA

View Full Version : Decimal Point In Forms


schnitzel_21st
12-24-2003, 01:01 AM
Hello, i'm trying to make a rpm/ratio/speed calculator, but in my the calculation in my form, it only seems to be using the numbers before the decimal point (whole numbers) not the decimals so im getting strange results :(

here's an example of what i'm doing:


<form name="calc">
<input type="text" name="A" value="0.5" size="10">
<input type="text" name="B" value="0.5" size="10">
<input type="button" name="mult" value="Multiply" onClick="document.calc2.C.value =
parseInt(document.calc2.B.value) *
parseInt(document.calc2.A.value)">
<input type="text" name="C" size="10">
</form>


could you please edit this code to make it work correctly :)

n8thegreat
12-24-2003, 01:02 AM
use parseFloat instead of parseInt

schnitzel_21st
12-24-2003, 01:11 AM
Thanks