Calculate values

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

opps – here is the fla

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

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 :slight_smile:

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

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?

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?

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]

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

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)

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.

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

Do you mean instead of ActionScript?

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