10 Replies Latest reply on Jan 24, 2015 12:43 AM by try67

# Custom Calculation Help

I need help writing a custom calculation.  This is what I need:  I have four checkboxes (Tone4, Tone3, Tone2, Tone1).  Each checkbox is worth its value (ie. if Tone4 is checked, it should give me 4 points).  How do I write a script that will give me the right value for the checkboxs?

Tone4     Tone3     Tone2     Tone1     ToneScore

x                                                            4

or

Tone4     Tone3     Tone2     Tone1     ToneScore

x                                             3

or

Tone4     Tone3     Tone2     Tone1     ToneScore

x                               2

or

Tone4     Tone3     Tone2     Tone1     ToneScore

x               1

or

Tone4     Tone3     Tone2     Tone1     ToneScore

0

• ###### 1. Re: Custom Calculation Help

Why are these boxes named differently? If they are a part of an exclusive group (ie, you shouldn't tick more than one at a time) then they should have the same name but different export values. Then you can just set the desired values as the export values for each box and use this code as the custom calculation script of ToneScore:

event.value = this.getField("Tone").value;

if (event.value=="Off") event.value = 0;

• ###### 2. Re: Custom Calculation Help

If I could kiss you through this computer, I would!  I spent two hours trying to figure this out.  You are the man!!!!!!  My fellow music teachers will LOVE you too.  This will be put into a sheet we all use county wide to grade students and make our lives so much easier.  Thank you!  THANK YOU!!!!!!

• ###### 3. Re: Custom Calculation Help

ok.  I thought I could figure out the last one but I can't.  Can I ask for one more quick help.

How do I take one score and multiply it and show the value.  For instance......

ToneScore * 5?

• ###### 4. Re: Custom Calculation Help

Enter exactly that as the "Simple Notation" script under the field's Calculate tab (the second option).

• ###### 5. Re: Custom Calculation Help

Here's another for you..........So, i have a calculation field going.  What do I do if I want to have another box display a conditional statement:

Total score 17  Rating Score Good

The scoring would go like this:

Total Scores: 7-10 Superior, 11-17 Good, 18-24 Fair, 25-28 Unsatisfactory

Gilad:  I can't thank you enough.  I know that these may be simple questions but I really do appreciate it.  It is revolutionizing the way we are doing contests in my county and my other directors, high school and middle school, have already been emailed a pdf that you helped create.  That's 47 other people that you have helped do their job quicker, easier, more efficiently, and correctly (lack of human error!).  Thank you for all that you do to help us.

Z

• ###### 6. Re: Re: Custom Calculation Help

You can use something like this as the field's custom calculation script:

```var totalScore = Number(this.getField("Total Score").valueAsString);
if (totalScore>=7 && totalScore<=10) event.value = "Superior";
else if (totalScore>=11 && totalScore<=17) event.value = "Good";
else if (totalScore>=18 && totalScore<=24) event.value = "Fair";
else if (totalScore>=25 && totalScore<=28) event.value = "Unsatisfactory";
else event.value = "";
```
• ###### 7. Re: Re: Custom Calculation Help

Ok, so this is the last one for quite some time.  How do I have a text box that will show the value of 1 whether the person adds a "1" or "A", "2" or "B", etc.  I am betting that this has to be done through the validation field which I have no idea about.  Is it even possible?

Z

• ###### 8. Re: Re: Custom Calculation Help

I don't understand what you mean... Please clarify.

• ###### 9. Re: Re: Custom Calculation Help

If I place the letter A or the number 1 in a box, I want it to numerically count for "1" all of the time.

Basically, it's two different ways to grade but still mean the same thing.  Best example is a "4.0" in college would be also called "Straight A's" in high school.  Does that make sense?

Z

• ###### 10. Re: Re: Custom Calculation Help

A text field doesn't have an "export value". You will need to include this logic in your calculation scripts.