Skip to main content
Participant
March 20, 2023
Answered

Dropdown selection reveals different notice depending on the selection?

  • March 20, 2023
  • 1 reply
  • 670 views

I am trying to consolidate a form by having the client select their state and that selection then reveals only the legal notice required for the selected state, insted of providing everyone every notice. I'm not even sure the best way to go about this, so looking for suggestions. 

This topic has been closed for replies.
Correct answer try67

You can create a (read-only) text field for the notice and populate it with the desired text when a selection is made in the drop-down. To do so you can use something like this as the custom Validation script of the latter (let's say the text field is called "LegalNotice"):

 

if (event.value=="Alaska") this.getField("LegalNotice").value = "Legal notice text for Alaska...";
else if (event.value=="Alabama") this.getField("LegalNotice").value = "Legal notice text for Alabama...";
else if (event.value=="New York") this.getField("LegalNotice").value = "Legal notice text for New York..."; // etc.
else event.value = ""; // No notice for all other states not in the code above

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 20, 2023

You can create a (read-only) text field for the notice and populate it with the desired text when a selection is made in the drop-down. To do so you can use something like this as the custom Validation script of the latter (let's say the text field is called "LegalNotice"):

 

if (event.value=="Alaska") this.getField("LegalNotice").value = "Legal notice text for Alaska...";
else if (event.value=="Alabama") this.getField("LegalNotice").value = "Legal notice text for Alabama...";
else if (event.value=="New York") this.getField("LegalNotice").value = "Legal notice text for New York..."; // etc.
else event.value = ""; // No notice for all other states not in the code above
Known Participant
September 5, 2023

@try67 How can Clear the Field if the dropdown is not selected? I tested in my case if the dropdown made empty the text field still has the text populated based on the dropdown. 

try67
Community Expert
Community Expert
September 5, 2023

The last line of code should handle that situation, assuming you have a default value for the drop-down that isn't one of the state names.