Real time updating of values on a form
So I have 2 input fields where the user types something into a form. They press "calculate" and then the function totals up what they have entered and then calculates 1,2 and 3% for each value respectively. It looks something like this:
input 1%value input 2%value input 3%value total total
If you want to display 'realtime' (meaningly, as the user types) values, you can use the keyup values :
- http://api.jquery.com/keyup/ (for jquery)
<input name="something" type="text" onblur="calculateStuff();" value="">
The onBlur event happens when the user leaves the field. If you want it to happen as they are still typing, you could use the onChange handler in the same way.
You can also add other event listeners such as blur etc.
It has been a while so i cant post any usable code but Google is your friend here.
Without building a complete answer for you here are some hints:
edit: you can use the onchange event to process the changes
It's simple! Instead of using the button, add an onChange="your_calculate_function()" attribute to each of your inputs.