Skip to main content
Known Participant
June 1, 2016
Answered

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

  • June 1, 2016
  • 1 reply
  • 637 views

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.

This topic has been closed for replies.
Correct answer try67

Sure. Use this code instead of the one above:

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

1 reply

try67
Community Expert
Community Expert
June 1, 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 = "";

pdfUser1Author
Known Participant
June 1, 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?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 1, 2016

Sure. Use this code instead of the one above:

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