8 Replies Latest reply on May 22, 2006 1:51 AM by Mike Crisp

# How to display and calculate a total in text fields

Hi

I am building a Risk assessment matrix and need to perform some simple calculation.

1st. On a MouseUp event (e.g. Danger on a scale of 1 to 5 the user clicks box 5 for weather) I want to display a score in a text field.

2nd when the user has clicked all of the boxes I need the final Total score box to either be automatically updated or click a calculate button and show the total score in the all the text fields.

Any suggestions or examples.

Mike
• ###### 1. Re: How to display and calculate a total in text fields
Ok

so the first bit was easy to figure out:

on mouseUp me
member("Location").text = "5"
end

Replicate this for each 'Box' (location, weather, equipment, Transport, First aid)

Now how do I add the .text="x" for those five boxes to give a grand total in Box - member("Total").text = "y"
• ###### 2. Re: How to display and calculate a total in text fields
member("Total").text = string(value(member("Location").text ) +
value(member("weather").text ) + value(member("equipment").text ) +
value(member("Transport").text ) + value(member("First aid").text ))

• ###### 3. Re: How to display and calculate a total in text fields
Dave

Thanks, that was perfect.

Best regards

Mike
• ###### 4. Re: How to display and calculate a total in text fields
Dave

Now that I've started tinkering. Any suggestions as to how I might work the following:

If value of member "total".text is between 8 and12 Member"Risk Level".text = "Low Risk"

If value of member "total".text is higher than 27 Member"Risk Level".text = "Unaccepable"

And so on.....

Mike
• ###### 5. Re: How to display and calculate a total in text fields
Sort of answered my problem by moving to a new frame with the following:

if value(member("Total").text) > 10 then
go to frame 55

end if

if value(member("Total").text) > 25 then
go to frame 60

END IF
End

BUT would be interested to know, for the sake of my learning, how I would have written the code using "value" and "member "
• ###### 6. Re: How to display and calculate a total in text fields
You can define any number of risk levels (low, medium, high, etc) using a
case statement

case (true) of
(value(member("total")) < 12): member("risk level").text = "Low"
(value(member("total")) < 27) : member("risk level").text = "Medium"
otherwise:member("risk level").text = "High"
end case

"Mike Crisp" <webforumsuser@macromedia.com> wrote in message
news:e4kn47\$b2n\$1@forums.macromedia.com...
> Dave
>
> Now that I've started tinkering. Any suggestions as to how I might work
the
> following:
>
> If value of member "total".text is between 8 and12 Member"Risk
Level".text =
> "Low Risk"
>
> If value of member "total".text is higher than 27 Member"Risk Level".text
=
> "Unaccepable"
>
> And so on.....
>
> Mike
>

• ###### 7. Re: How to display and calculate a total in text fields
Oops, typo

case (true) of
(value(member("total").text) < 12): member("risk level").text = "Low"
(value(member("total").text) < 27) : member("risk level").text =
"Medium"
otherwise:member("risk level").text = "High"
end case

• ###### 8. Re: How to display and calculate a total in text fields
Dave

Again thats great.