Skip to main content
ZombieLuna
Inspiring
March 14, 2019
Answered

Fill Text Box Based on Selection Made in Drop Down

  • March 14, 2019
  • 1 reply
  • 691 views

So, I've found a few suggestions in the forum on how to do this, but I can't make it work, and my situation is much simpler than all the other conversations that I can find.

I have a Drop Down menu ("Banked Weeks") that contains two options: "No" and "Yes".

No is the default selection and remains there at all times, but the user can switch it to Yes.

I then have a text box ("How Many") that I want to autofill with "None" when "No" is selected and be fillable - and become required - when "Yes" is selected.

Any help would be appreciated.

This topic has been closed for replies.
Correct answer try67

Sorry, in the first line it should be "How Many", not "Banked Weeks"...

1 reply

try67
Community Expert
Community Expert
March 14, 2019

As the custom validation script of the drop-down field enter the following code:

var f = this.getField("Banked Weeks");

f.readonly = (event.value=="No");

f.required = (event.value=="Yes");

f.value = (event.value=="No") ? "None" : "";

ZombieLuna
Inspiring
March 14, 2019

So, that did what you told it to, but that's not exactly what I wanted to happen...

The drop down doesn't need to be read only ever.

And I would like the Text Field "How Many" to become required and fillable when the drop down "Banked Weeks" says "Yes"

While, when the drop down says "No", the text field "How Many" auto fills with 'None'.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 14, 2019

Sorry, in the first line it should be "How Many", not "Banked Weeks"...