If you have a number of boxes that you want the user to enter numbers into, that are then added up…
if they put a non number in you get “NaN” displayed
does that mean you have to do a if() test on every entry to ensure that a number has been entered, and if one hasn’t its to be replaced with 0 ?
if that is the case what is the if (clause ); please
Also in relation to this, if a user inputs a number into a input text field, is it possible that this is imediatley updated into a dynamic text field… or do you HAVE to asign a button to do this ?
I looked at you code and tried to create the addition function but I as yet can not get it to function. Below is the code.
[AS]
sushi_plater_order = 0; //input text field
chop_stick_order = 0; //input text field
wasabi_order = 0; //input text field
sushi_plater_total = 0; //dynamic text field
chop_stick_total = 0; //dynamic text field
wasabi_total = 0; //dynamic text field
_total = 0; //dynamic text field
This half works, that is if a letter or nothing is entered it sets the value to 0 so that you dont get NaN. However even when putting a number in there it still sets it to 0.
From what I can tell, you’re using variables and not the instance names.
The onChanged handler is a TextField event, and restrict is a TextField property. You’ll need to assign instance names to your TextFields, and update the code to use the instance names and not the variables.
Also, you could use the isNaN function:
[AS]if (isNaN(sushi_plater_order)) sushi_plater_order = 0;[/AS]
[EDIT]lol @ senocular :P[/EDIT]
Ive only been really lucky so far (I do it by reading your mind and posting your thoughts first making it seem as if they were mine and taking all the credit for it ;))