Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 210
zik Avatar asked Jun 22 '11 14:06

zik


1 Answers

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

  • http://www.w3schools.com/jsref/event_onkeyup.asp (for pure javascript)
  • http://api.jquery.com/keyup/ (for jquery)
like image 189
JMax Avatar answered Sep 28 '22 15:09

JMax