# Adding Variables from Input Text Fields

**URL:** <https://forum.kirupa.com/t/adding-variables-from-input-text-fields/260480>\
**Category:** flash\
**Created:** [May 16, 2008, 2:38am UTC](https://forum.kirupa.com/t/adding-variables-from-input-text-fields/260480 "2008-05-16T02:38:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThaJock](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@ThaJock](https://forum.kirupa.com/u/ThaJock)\
**Post date:** [May 16, 2008, 2:38am UTC](https://forum.kirupa.com/t/adding-variables-from-input-text-fields/260480/1 "2008-05-16T02:38:02Z")

</div>

Flash 9/AS2

I’m still new to flash as and I have a form that will require the user to type in some figures (into the input text fields) which will need to be totaled up at the end.

Would it be recommended to execute this function by sending it to php and then back to flash or is there a better way to do it within flash?

Again all I want to do is get the sum of all input text variables (all having number values).

---

<div class="post-metadata">

**Author:** ![jon\_bla](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jon\_bla](https://forum.kirupa.com/u/jon_bla)\
**Post date:** [May 16, 2008, 3:53pm UTC](https://forum.kirupa.com/t/adding-variables-from-input-text-fields/260480/2 "2008-05-16T15:53:23Z")

</div>

you can do math inside of flash.  
here is an eg:

```auto

num1:Number = int(input_txt1.text);
num2:Number = int(input_txt2.text);
num3:Number = int(input_txt3.text);
num4:Number = int(input_txt4.text);

//do your math function now

total= num1+num2+num3+num4;
trace(total);

```

---

<div class="post-metadata">

**Author:** ![ThaJock](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@ThaJock](https://forum.kirupa.com/u/ThaJock)\
**Post date:** [May 16, 2008, 5:38pm UTC](https://forum.kirupa.com/t/adding-variables-from-input-text-fields/260480/3 "2008-05-16T17:38:09Z")

</div>

Ok, thanks for the reply. This form is one that has the user fill out info on the first page (frame 1) then to get to the next page (frame 2) the user hits the next buttons. There are a total of 4 pages. So my first question is which frame do I put this acton script? My second question is where will the sum appear.

---

<div class="post-metadata">

**Author:** ![jon\_bla](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jon\_bla](https://forum.kirupa.com/u/jon_bla)\
**Post date:** [May 16, 2008, 6:52pm UTC](https://forum.kirupa.com/t/adding-variables-from-input-text-fields/260480/4 "2008-05-16T18:52:28Z")

</div>

use it on the frame where the text box is
