Highlighted

## How to formulate custom calculation script (if this is even possible).

New Here ,
Aug 11, 2020

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;

Is there a way to make the "Square" value match whatever is in field "Text10" ?

TOPICS
PDF forms

Views

50

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

## How to formulate custom calculation script (if this is even possible).

New Here ,
Aug 11, 2020

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;

Is there a way to make the "Square" value match whatever is in field "Text10" ?

TOPICS
PDF forms

Views

51

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
6 Replies 6
Most Valuable Participant ,
Aug 11, 2020

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.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
New Here ,
Aug 11, 2020

Copied

It works now after I removed the export values, but I wanted to add/change an additional variable if that makes sense?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
New Here ,
Aug 11, 2020

Copied

Is it even possible to change the drop-down options to whatever the person filling the pdf enters in "Text10"?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
Most Valuable Participant ,
Aug 11, 2020

Copied

Sorry, I don't follow what you mean.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
New Here ,
Aug 11, 2020

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?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
LATEST
Most Valuable Participant ,
Aug 11, 2020

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

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 11, 2020 0
Resources