-
howtodo:simple addition
Hello friends,
I am trying to add values of 5 inputfields.
1st value1
2nd value2
3rd value3
4th value4
5th value5
6th totalval
when i enter number in value 1 and press tab the totalval field should show up the value of 1st then in after entering number in value2 and tab, totalval should show up addition of 1and2 and like this so on..
not getting how to get this done.. can someone guide me.
thanks..
-
Originally Posted by viva_for_ever
Hello friends,
I am trying to add values of 5 inputfields.
1st value1
2nd value2
3rd value3
4th value4
5th value5
6th totalval
when i enter number in value 1 and press tab the totalval field should show up the value of 1st then in after entering number in value2 and tab, totalval should show up addition of 1and2 and like this so on..
not getting how to get this done.. can someone guide me.
thanks..
Try this
Code:
this.onEnterFrame = function() {
if (Key.isDown(Key.TAB)) {
_root.totalval.text = Number(_root.value1.text) + Number(_root.value2.text) + Number(_root.value3.text) + Number(_root.value4.text) + Number(_root.value5.text);
}
}
Discription:
Every frame the code tests for the tab key being down.
if it is down, it adds the values in all of the text boxes and sticks it in total
The boxes hhould have instance names value1 value2 value3 etc.
Place this in the code for the frame.
-
Hi friend, thanks for the code, but when i test movie and as i enter 1st number it gives me "NaN" in dynamic field which is having instant name as totalval. can u tell me why is this comming.. am i doing some mistake?
-
Maybe you need to set totalval to something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|