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

How can I have 7 txt fields calculate and/or show/hide?

Participant ,
May 31, 2016 May 31, 2016

I have 7 txt fields. Like so, ST1, ST2, ST3...ST7. With 1 TotalST field for all the "ST" fields (which calculates the totals the fields). What I would like to do is, when the ST fields are not populated then the TotalST field would be hidden. When one or all the ST fields are populated the TotalST field would be visible, but also calculates the ST fields. Then the TotalSt would hide if I delete the input from all the ST fields.

At the moment I have the calculation working fine (pretty simple) using the Simplified window. But, I think, this needs a javascript that would have to be placed in the Custom Calculation window. So, can someone provide a script that would do what I'm hoping to do? Thanks.

TOPICS
Acrobat SDK and JavaScript , Windows
577
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

correct answers 1 Correct answer

Community Expert , Jun 01, 2016 Jun 01, 2016

Sure. Use this code instead of the one above:

event.target.display = (event.value==0) ? display.hidden : display.visible;

Translate
Community Expert ,
Jun 01, 2016 Jun 01, 2016

You want to actually hide the field, or just not show the "0" value?

If the latter then simply enter this code as its custom validation script:

if (event.value==0) event.value = "";

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
Participant ,
Jun 01, 2016 Jun 01, 2016

How would I show/hide the fields? Your script works to not show the "0". But, I'd like to show the field when the ST fields are populated, when not, then to hide the TotalST field. Can that be done?

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 ,
Jun 01, 2016 Jun 01, 2016

Sure. Use this code instead of the one above:

event.target.display = (event.value==0) ? display.hidden : display.visible;

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
Participant ,
Jun 01, 2016 Jun 01, 2016
LATEST

Works great!! Thank you

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