I am using this code for my form
Total: <input name="total" id="total" type="text" readonly="readonly" style="background-color:#eee;" value="<? echo $total; ?>" /><br /><br />
Cash: <input name="cash" id="cash" type="text" /><br /><br />
Change: <input name="change" id="change" type="text" readonly="readonly" style="background-color:#FF0;"/>
The total comes from php e.g 25.00, i want to be able to put a number e.g 30.00 in cash and then the change says e.g. 5.00 and i want it to change on key up so if i change the amount it re-calculates,
Can anyone help with the JavaScript to make the calculation work,thanks
Add an onchange and onkeyup event handler for the ‘cash’ element. Then make the calculations in the handler.
Example:
In Javascript: