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

How to auto update a form field based on a variable form field value changing?

Guest
Mar 22, 2022 Mar 22, 2022

Hi, 

Coding knowledge & experience non-existant so be gentle!  An approximation of the form is attached for


I have pdf form that needs to auto display a text based on the number displayed in another form field. Box with the score is 'Total' (this box auto sums numbers from other form fields, which also autosums from other fields). Based on the range of score, the form field named 'AutoSignificance' needs to display the appropriate text.

 

Now, with a lot of googling and trial and error I got the following code to work. Except it doesn't auto update everytime the scoring in 'Total' changes. If I click into the box, type something and come out it updates with the correct text. I've tried to run the script by using actions for the form field (mouse up, exit etc.), which didn't work. This is also not ideal, as this field needs to be auto completed, users of the form not selecting this box is why this endeavour started in the first place!

Then I wanted to use Document Actions (Document did save) to run the script but I couldn't figure out how to reference the 'AutoSignificance' form field. 

 

I'd take any help I can get here! The code I used in the 'AutoSignificance' form field is down below. Either:

 

1) A way to loop the code so that it runs based on the 'Total' changing or

2) a way to run the script when document is saved, in which case how do I reference the 'AutoSignificance' box in the script?

 

Code:

 

var v = this.getField("Total").value;
      if (v=="") event.value = "Complete Scoring";
      else {
            if (v>=1 && v<=10) event.value = "Non-Significant";
            else if (v>=11 && v<=13) event.value = "Apply Additional";
            else if (v>=14 && v<=20) event.value = "Significant";
}

TOPICS
How to , JavaScript , PDF forms
2.1K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 22, 2022 Mar 22, 2022

Use script as 'Custom calculation script' at 'calculate' tab.

In every dropdown field -> options tab, check 'Commit selected value immediately'.

View solution in original post

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 ,
Mar 22, 2022 Mar 22, 2022

Use script as 'Custom calculation script' at 'calculate' tab.

In every dropdown field -> options tab, check 'Commit selected value immediately'.

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
Guest
Mar 22, 2022 Mar 22, 2022
LATEST

Well that was easy! Thank you very much 🙂

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