How to formulate custom calculation script (if this is even possible).
Copy link to clipboard
Copied
I'm creating an interactive worksheet for a friend.
This worksheet has 3 shapes on it: a square, circle, and triangle. As well as a 24 Hour vs day of the week chart.
He wants there to be a custom entry in each shape that will also auto-populate as 3 selections in a dropdown menu for each hour slot. These 3 options will need to be calculated back as hours spent in each shape.
This is what it currently looks like
It uses:
var total = 0;
for (var i=1; i<=168; i++) {
if (this.getField("M1."+i).valueAsString=="Square") total++;
}
event.value = total;
Copy link to clipboard
Copied
Since I wrote the code for you I feel obliged to add that the drop-downs have the same export values for all items, which is why it's not working. You have to give each item a unique export value, or stop using them at all.
Copy link to clipboard
Copied
It works now after I removed the export values, but I wanted to add/change an additional variable if that makes sense?
Copy link to clipboard
Copied
Is it even possible to change the drop-down options to whatever the person filling the pdf enters in "Text10"?
Copy link to clipboard
Copied
Sorry, I don't follow what you mean.
Copy link to clipboard
Copied
So the workflow is
1) The person filling this PDF will name each shape in text boxes "Text10" "Text11" "Text12" with an activity
2) They want those activities to then populate in the dropdowns in the chart above. (I don't think this is possible?)
3) Then they want the calculation within the shapes ("Total Square Time") below to still calculate how many hours are spent doing that activity.
I'm guessing that it's not possible to connect whatever is typed in "Text10" as a dropdown option, so perhaps I could have the calculations in "Total Square Time" to count only things typed into M1.+i that match Text10?
Copy link to clipboard
Copied
Changing the items in the drop-downs is tricky. Which ones should be changed? When? etc.
The second option is easier. To do it just change this part of the code:
this.getField("M1."+i).valueAsString=="Square"
With:
this.getField("M1."+i).valueAsString==this.getField("Text10").valueAsString

