Search code examples
javascripthtmlcssforms

Real time updating of values on a form


Slightly related to my other question (which was answered) here, I was wondering if the following was possible (it likely is and very basic but I'm a bit noobish at JavaScript)!

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

Is there a way for me to be able to update the form in real time? So by this I mean, as soon as the user enters a value into a field the function automatically starts updating the values such as total etc? How would I go about achieving this, can it be done purely in JavaScript?

Thanks


Solution

  • If you want to display 'realtime' (meaningly, as the user types) values, you can use the keyup values :