I have several text fields on page that I would like to make calculations based on if there is a number input in one of the fields.
So, if the price field is populated, the sale price field would populate using a function to do the calculation.
Now, how do I write the code for this to occur? I know how to get the function to fire based on clicking a submit button, but not sure how to do it simply based on a number keyed into the one field.
Is this possible and if so, how? Thanks a ton.
You'd need to;
1) get a reference to the price field
2) remove whitespace
3) check it's length is more than 0
4) check it is a number
5) if all's fine, do your calculation.
Hope that's on the right track, fairly rushed reply and am trying to imagine your form.
Hope it helps.
What would force that function to fire though? Like I have functions that fire with the onClick. But what would I use to fire whenever?
ah sorry, you could use onblur (defocus) on the price field, but that may not be reliable enough, possibly onkeyup on the price field?
Ah ok, gotcha now. Thanks for the assist, I'll give all that a go.