These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Adding to calculation

HR Lady4
Registered: Nov 2 2010
Posts: 25

I currently have a custom script like this:
 
event.value = Sum(FieldNames2Values(["Score 1"]) );
 
I need that script to now take that value and multiply it by 25% or .25.
 
Can someone help?

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
A lot of code to get then value of a single field.

// get the value of 'Score 1' and multiply it by 0.25 or 25%
event.value = this.getField("Score 1").value * 0.25;

You had to previously use that code because you were trying to use the "+" operator and needed to eliminate empty fields from the calculation or you would have been concatenating the field values and not adding them.

George Kaiser

HR Lady4
Registered: Nov 2 2010
Posts: 25
I think I need to add more info.

So I have a "Section 1" with the custom script:

event.value = Sum(FieldNames2Values(["Score 1"]) );

I want that value to stay the same value as "Score 1"


I then have a "Section 2" with the custom script:

event.value = Sum(FieldNames2Values(["Score 2"]) );

I want that value to still show the same value as "Score 2"

I then have a section called "Overall Score"

That script looks like this:
event.value = Average(FieldNames2Values(["Score 1", "Score 2"]) );

However Section 1 is weighted at 25% and Section 2 is weighted at 75%

I then want that score to be in the "Overall Score". I guess I don't want it averaged like I have the script now, I just need it to weight the Section 1 and Section 2 and then add those together.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
A field can only have one value for a field with a given name. If you create a second field with the same name then that second occurrence of the field will have the same value as the first occurrence. Are you adding other fields to get the total value for the items in Section 1? If so, then you will need a differently named field for your weighted value. And the same for Section 2.

You can create hidden fields to contain the weighted value and then use the field names of the hidden weighted values to compute the average.

George Kaiser

HR Lady4
Registered: Nov 2 2010
Posts: 25
I think I will go back to the original plan. Section 1 and Section 2 will show the weighted score and then the Overall Score will sum(+) the Section 1 and Section 2.
HR Lady4
Registered: Nov 2 2010
Posts: 25
When I pick values from combo boxes it takes a long time or sometimes doesn't update at all.

Can a custom script be used to make it update faster?

I have a box called "Overall Rating" and I want it to add "Section 1" and "Section 2"

Right now it is using the standard sum(+) but takes forever and sometimes doesn't update.