View Full Version : how to do this

06-29-2006, 12:08 PM
i have a form

<input type="text" name="haha"><br/>

then i have a formular


how can i do instant showing when i input a value into the text field of "haha", mean, i enter the value of haha example 10 into the value, cost striaght show 7

06-29-2006, 12:35 PM
<input type="text" name="haha" onkeyup="this.form['cost'].value=Number((this.value*0.7).toFixed(2))">
<input type="text" name="cost">

I have used the combination Number() & toFixed() to avoid a possible error, as math operation with floated might accumulate small errors during binary-decimal-binary translation (the CPU uses binary to calculate and some decimal floated numbers are not finite in binary)