Skip to main content
Known Participant
August 17, 2025
Answered

Show/hide text field if certain words in another text field

  • August 17, 2025
  • 1 reply
  • 236 views

I would like to show a text field if the words "accrued dividends" are typed into another text field.  To complicate things, the words "accrued divedends" could be typed into one of 33 different text fields.  The 33 text fields are named B1, B2, B3...B33.  Thanks.

Correct answer Nesa Nurani

As a custom calculation script of the field which you want to show/hide use this:

var show = false;

for (var i=1; i <=33; i++) {
 var f = this.getField("B" + i).valueAsString;
  if (f && f.toLowerCase().indexOf("accrued dividends") !== -1) {
   show = true;
    break;}}

event.target.display = show ? display.visible : display.hidden;

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 17, 2025

As a custom calculation script of the field which you want to show/hide use this:

var show = false;

for (var i=1; i <=33; i++) {
 var f = this.getField("B" + i).valueAsString;
  if (f && f.toLowerCase().indexOf("accrued dividends") !== -1) {
   show = true;
    break;}}

event.target.display = show ? display.visible : display.hidden;
Known Participant
August 17, 2025

That works.  However, I would also like the field to hide again if "accrued dividends" is removed from the B1, etc. field.

Known Participant
August 17, 2025

Sorry, it does hide when I remove "accrued dividends" from B1.  Thank you!