# Calculate values

**URL:** <https://forum.kirupa.com/t/calculate-values/34308>\
**Category:** Uncategorized\
**Created:** [October 31, 2003, 5:10am UTC](https://forum.kirupa.com/t/calculate-values/34308 "2003-10-31T05:10:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![urbaneve](https://avatars.discourse-cdn.com/v4/letter/u/839c29/32.png) [@urbaneve](https://forum.kirupa.com/u/urbaneve)\
**Post date:** [October 31, 2003, 5:10am UTC](https://forum.kirupa.com/t/calculate-values/34308/1 "2003-10-31T05:10:42Z")

</div>

i need to create a thingy that calcuates values when entered and i am not sure what type of scripting i need to use

i have included the fla so you all have a general idea of what i need.

basicaly what i need is

items in step 1 to total  
items in step 2 to total  
then step 2 subtracted from step 1 to give me a total for step 3

---

<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:** [October 31, 2003, 5:11am UTC](https://forum.kirupa.com/t/calculate-values/34308/2 "2003-10-31T05:11:47Z")

</div>

opps – here is the fla

---

<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:** [October 31, 2003, 5:30am UTC](https://forum.kirupa.com/t/calculate-values/34308/3 "2003-10-31T05:30:42Z")

</div>

It’s just adding and subtracting :-\

section1 = values of all section 1 textboxes added together

section2 = values of all section 2 textboxes added together

section3 = section1-section2

---

<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:** [October 31, 2003, 5:44am UTC](https://forum.kirupa.com/t/calculate-values/34308/4 "2003-10-31T05:44:46Z")

</div>

for the most part but – there will be some multipling and such too… so grab a coke and the donuts this is going to be a doosey… _snirt_

in step 1  
rate of pay x hours worked + benefits = total

in step 2 for 'per project’  
hours needed x rate (this amount is static and wont change) = total  
----- and ----- (this is where it gets complicated)

for 'monthly retainer’  
hours retained (wether being 15, 25 or 40) the valules are going to change  
15 hours = 23.00 an hour  
25 hours = 21.00 an hour  
40 hours = 17.50 an hour to give the amount in the rate box and then give a total

in step 3  
total from step 1 minus the totals is step 2 to give a value for step 3

i know it seems a little confusing, i hope i explained it well enough 🙂

---

<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:** [October 31, 2003, 5:46am UTC](https://forum.kirupa.com/t/calculate-values/34308/5 "2003-10-31T05:46:23Z")

</div>

actually in step 1 — i took out the 401k - - misc and the tax input boxes so all that i need is to multiply hours by rate plus benefits for a total

---

<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:** [October 31, 2003, 5:51am UTC](https://forum.kirupa.com/t/calculate-values/34308/6 "2003-10-31T05:51:11Z")

</div>

Well you have your equations down, I don’t see where you would need help :-\

Unless you don’t know how to get the value from the textbox?

---

<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:** [October 31, 2003, 5:54am UTC](https://forum.kirupa.com/t/calculate-values/34308/7 "2003-10-31T05:54:35Z")

</div>

yeah – i dont know what to put where and how to write out the script. do you know of a tutorial or example i can use?

---

<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:** [October 31, 2003, 6:00am UTC](https://forum.kirupa.com/t/calculate-values/34308/8 "2003-10-31T06:00:24Z")

</div>

Well I see you are using var names for your textboxes, so that is easy enough. An example (of adding them all, just as an example) would be (on a frame) like this…

[AS]total1 = rate1+hours1+taxes+fourOhOne+pto+misc[/AS] I had used “fourOhOne” because you can use numbers for a var or instance name.

So basically on a frame you would want to make a function to do this… something like… [AS]function getFinalValue(){  
total1 = doThatEquationThingHere;  
total2 = doItAgainHereForTotal2Textboxes  
total3 = whateverHere  
}[/AS] Then you can create a submit button and call it like this [AS]on (release){  
getFinalValue();  
}[/AS]

---

<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:** [October 31, 2003, 6:08am UTC](https://forum.kirupa.com/t/calculate-values/34308/9 "2003-10-31T06:08:18Z")

</div>

great thanks — i am gonna start on the script tomorrow ( i’m going on 26 hours of no sleep)

i’ll let you know tomorrow how its going.

thanks again

---

<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:** [November 2, 2003, 1:24am UTC](https://forum.kirupa.com/t/calculate-values/34308/10 "2003-11-02T01:24:33Z")

</div>

okay - i have it working — but i have another question. is there a way to automatically display a value when another value is entered in on another box

here’s an example

if a user inputs “15” into box 1 i need for it to display “22.00” into box 2 – or if they enter in “25” – it displays 20.00 etc

(ps – here is the form in action so far, minus the graphics the text in blue is the hours to be manually entered and the text in yellow is what i need for it to automatically display)

thanks

(oh and one more thing — is it possible to set it up where when the user inputs something other than a numeriacl value – a message pops up saying " please enter numberic values only"

i am assuming it works on an “if” statement. i just dont know how to write the script)

---

<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:** [November 2, 2003, 2:52am UTC](https://forum.kirupa.com/t/calculate-values/34308/11 "2003-11-02T02:52:47Z")

</div>

Problem 1: Use an onChanged dynamic event handler for each textbox. For this you will need to give your textboxes an INSTANCE name (in the properties panel) and target it like… [AS]textBoxInstanceName.onChanged = getFinalValue;[/AS] That will then run the getFinalValue function whenever the content of the textbox changes.

Problem 2: The wonderful world of restrict. Again, the textbox will need an INSTANCE name. Then you can run it like [AS]textBoxInstanceName.restrict = “0-9”;[/AS] That will only enable you to use the characters 0 through 9 in that textbox.

---

<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:** [November 2, 2003, 4:01am UTC](https://forum.kirupa.com/t/calculate-values/34308/12 "2003-11-02T04:01:01Z")

</div>

i see what you are saying – is it possible to do with java or php or such do you think

---

<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:** [November 2, 2003, 4:05am UTC](https://forum.kirupa.com/t/calculate-values/34308/13 "2003-11-02T04:05:05Z")

</div>

Do you mean instead of ActionScript?

If so, you can with JavaScript, but it won’t be as easy as with ActionScript.
