Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Aug 11, 2020 Aug 11, 2020

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 

Screen Shot 2020-08-11 at 7.43.07 AM.pngexpand image

 

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
666
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2020 Aug 11, 2020

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.

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

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

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2020 Aug 11, 2020

Sorry, I don't follow what you mean.

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

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? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2020 Aug 11, 2020
LATEST

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

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