Skip to main content
Participating Frequently
June 12, 2024
Answered

Dropdown menu to dictate when a textfield can be used, need some assistance on formatting please

  • June 12, 2024
  • 3 replies
  • 409 views

I have almost finalised my form, however I have another query/question for the Adobe Community.

I am trying to dictate the form in the signature fields to only become available editable when a drop down option is selected.

 

The only thing is I am basing this off our ai travel policy.

in brief 

if any of the following Air Travel Type field Options are selected

-  Intrastate 

- Interstate

-International 

 

the following signature name fields and siganature fields should then activate or deactivate

Intrastate ('Recommended by' Row or fields across is deactivated and not made available for edit, All other rows and their fields become available for edits)

Intertstate ( All rows and their fields become available for edits)

International (All rows and their fields become available for edits)

 

hopefully the explanation is clear 

 

See screen shot below, please note the script below was an attempt and used a sample that Nesa had provided in the community page, but again I am sure this can be very simplified and there are many other script characters that are needed for the action to take effect, thanks again community in advance.

 

 

regards

 

Malo

This topic has been closed for replies.
Correct answer Nesa Nurani

The script from try67 will work fine, but if you need an even shorter version:

var signatureFields = {
"Intrastate": ["a1", "a2", "a3"],
"Interstate": ["b1", "b2", "b3"],
"International": ["c1", "c2", "c3"]};

for (var type in signatureFields) {
for (var i in signatureFields[type]) {
var f = this.getField(signatureFields[type][i]);
f.display = (event.value == type) ? display.visible : display.hidden;}}

3 replies

Participating Frequently
June 13, 2024

evening yes both answers, provide the same outcome, thank you very much try67 and Nesa.

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
June 13, 2024

The script from try67 will work fine, but if you need an even shorter version:

var signatureFields = {
"Intrastate": ["a1", "a2", "a3"],
"Interstate": ["b1", "b2", "b3"],
"International": ["c1", "c2", "c3"]};

for (var type in signatureFields) {
for (var i in signatureFields[type]) {
var f = this.getField(signatureFields[type][i]);
f.display = (event.value == type) ? display.visible : display.hidden;}}
try67
Community Expert
Community Expert
June 12, 2024

That code should work, but if you want a shorter version of it you can use this:

 

var intrastateSignatureFields = ["...", "..."];
var interstateSignatureFields = ["...", "..."];
var internationalSignatureFields = ["...", "..."];

for (var i in intrastateSignatureFields) {
	var f = this.getField(intrastateSignatureFields[i]);
	f.display = (event.value=="Intrastate") ? display.visible : display.hidden;
}

for (var i in interstateSignatureFields) {
	var f = this.getField(interstateSignatureFields[i]);
	f.display = (event.value=="Interstate") ? display.visible : display.hidden;
}

for (var i in internationalSignatureFields) {
	var f = this.getField(internationalSignatureFields[i]);
	f.display = (event.value=="International") ? display.visible : display.hidden;
}

 

You just need to fill in the names of the fields in the first three lines, of course.