Skip to main content
Participant
November 9, 2019
Answered

PDF Form - Is it possible to link drop down menu to variable text fields?

  • November 9, 2019
  • 1 reply
  • 1012 views

I would like to know if there is a JavaScript to do the following - 

 

Drop down list = "Fact" or "Opinion"

Next to each drop down is a text field called "Dislike1" which is a custom entry by user. (they write what they dislike and then use the dropdown to identify if it's a fact or opinion)

If they select Fact for Dropdown1, I would like to replicate "Dislike1" in another text field. If they select Opinion, I would to replicate "Dislike1" into a different text field.

 

The goal is to build a separate list for Facts and a separate list for Opinions, each on separate pages, without user having to retype their Dislikes. Since the lists would build, then the text fields would have to be variable (if they choose Fact 3x in a row, then those text fields go to the Facts page, then if they choose Opinion in the 4th row, that would have to be the first text field on the Opinions page).

 

This may not be possible...but??? The preliminary form is linked below.

Fact vs Opinion PDF Fillable Form 

 

Thank you!

This topic has been closed for replies.
Correct answer ls_rbls

Hi,

 

I haven't tested this little code yet on my end but you can see if it works.

 

in the Dropdown1 field Properties --> Format tab---> Custom Keystroke Script use something like this :

 

if (!event.willCommit){this.getField("Dislike1").value=event.changeEx;}

 

 

OR,

 


in the Custom Format Script section add something like:

 

if(!event.willCommit)

console.println(!event.value);

 

  • NOTE: make sure to also visit the Options tab and tick the box that says "Commit selected value immediately"


Then in the field that you need to copy the contents of the textfield "Dislike1" put a line of code in the custom calculation tab like this:

 

var a = this.getField("Dislike1").value;
var b = this.getField("Dropdown1").value;
if (a=="") event.value = "";
if (b==''") event.value = "";
else if (b==Opinion) event.value = "";
else if (b==Fact) event.value = a;

1 reply

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
November 12, 2019

Hi,

 

I haven't tested this little code yet on my end but you can see if it works.

 

in the Dropdown1 field Properties --> Format tab---> Custom Keystroke Script use something like this :

 

if (!event.willCommit){this.getField("Dislike1").value=event.changeEx;}

 

 

OR,

 


in the Custom Format Script section add something like:

 

if(!event.willCommit)

console.println(!event.value);

 

  • NOTE: make sure to also visit the Options tab and tick the box that says "Commit selected value immediately"


Then in the field that you need to copy the contents of the textfield "Dislike1" put a line of code in the custom calculation tab like this:

 

var a = this.getField("Dislike1").value;
var b = this.getField("Dropdown1").value;
if (a=="") event.value = "";
if (b==''") event.value = "";
else if (b==Opinion) event.value = "";
else if (b==Fact) event.value = a;

Participant
November 18, 2019

Thanks so much - yes, it did work! I have had some issues with the way I designed the form in general so have to change it up a bit. 

ls_rbls
Community Expert
Community Expert
November 18, 2019

That is great! you're welcome.