Skip to main content
Known Participant
Aug 17, 2025 3:13 AM UTC
Answered

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

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.

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Aug 17, 2025 8:53 AM UTC

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;

3 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Aug 17, 2025 8:53 AM UTC

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;
Translate
Known Participant
Aug 17, 2025 3:15 PM UTC

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

Translate
Known Participant
Aug 17, 2025 3:52 PM UTC

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

Translate