# Add 3 values from input text boxes, display total

**URL:** <https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659>\
**Category:** flash\
**Created:** [April 30, 2003, 8:47am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659 "2003-04-30T08:47:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GregD](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@GregD](https://forum.kirupa.com/u/GregD)\
**Post date:** [April 30, 2003, 8:47am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659/1 "2003-04-30T08:47:00Z")

</div>

Hey people,

Just a quick query here, I want to be able to add the sum of 3 input text boxes and have the total be displayed in another text box.

I figure I set a variable and do something along the lines of:

```
Number = "_root.input1 + _root.input2 + _root.input3";

```

Or do I have to do this another way?

Also where should I put the code? In a button? Or can I stick it in the frame to save complications of users clicking on a button.

Thanks

G

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2003, 9:16am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659/2 "2003-04-30T09:16:54Z")

</div>

you can use the onChanged event handler so you don’t need to click any button.

that would be something like this:

```auto
input1.onChanged = input2.onChanged=input3.onChanged=function() {
	output.text = Number(input1.text)+Number(input2.text)+Number(input3.text);
};

```

hope it helps… =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2003, 10:02am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659/3 "2003-04-30T10:02:35Z")

</div>

Thanks, I have got a bit further now, the main problem im having though is getting the values to add properlly, currently I have:

on (release) {  
output = \_root.output;  
input1 = \_root.input1;  
input2 = \_root.input2;  
output = input1 + input2;  
}

But instead of adding 1 + 1 to make 2… it just makes it 11

This is obviously a formating thing or something to do with the value being boolean, I can’t remember. If you can shed some light on this so the values are actually adding correctly I would be grateful.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2003, 10:07am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659/4 "2003-04-30T10:07:32Z")

</div>

that’s why i used **Number(whatever)**. flash interprets those values as strings. :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2003, 10:26am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659/5 "2003-04-30T10:26:38Z")

</div>

Yeah got that working thanks! But I can’t get decimal points now…

Say 15 divided by 2 = 7.5 I just get 75 🙂

on (release) {  
output = \_root.output;  
output2 = \_root.output2;  
input1 = \_root.input1;  
input2 = \_root.input2;  
input3 = \_root.input3;  
output = (Number(input1) + Number(input2));  
output2 = (Number(output) \* Number(input3));  
}

I eventually want to have an average and a percentage in 2 diff boxes.

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2003, 10:56am UTC](https://forum.kirupa.com/t/add-3-values-from-input-text-boxes-display-total/19659/6 "2003-04-30T10:56:49Z")

</div>

S’ok got it working i hadnt allowed a . and a - in the dynamic text fields 🙂
