Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Use Textbox in one form to Populate Dropdown in other form

New Here ,
Feb 15, 2023 Feb 15, 2023

I have a multiline text box (List of possible names) in form #1 that i am trying to use to populate a dropdown box in form #2 where the user will select a name from that list for a specific response.
I tried FDF to export out from form #1 and import into form #2 with no luck. "Textbox" to "Dropdown" via FDF does not push the contents of the textbox into the dropdown. I have tried to populate a 'helper' dropdown in form number 1 and then use the FDF export/import process (so i am moving data from a dropdown in form #1 to a dropdown in form #2) but this also was unsuccessful.

 

i am hopeful the community may have a suggestion.

Please let me know if additional info is needed.

 

thank you all kindly in advance.

TOPICS
How to , JavaScript , PDF forms
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2023 Feb 16, 2023

Not directly, no. However, what you can do is populate another (hidden) text field with the names from the original field, and then use a script to populate the items in the drop-down with those names.

The latter code would be something like this:

 

var names = this.getField("Names").valueAsString;

this.getField("NamesList").setItems(names.split("\r"));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2023 Feb 16, 2023

Aha! Of course. I just had my 'helper' on the wrong side of the FDF process.

 

thank you @try67 !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2023 Jun 02, 2023

@try67 Hello Again,
Could use your advice and instruction: without observable reason the code snippet you shared is populating my dropdown list of names on a single line. What modifications to the code should i make to locate each name on a new line within the dropdown? 


A sample list of names might include:
Robert Abrams

Sydney Carstle
Emma Vognier

Juliette Washington

thank you again for the assistance.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2023 Jun 03, 2023

Post your exact code, please.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2023 Jun 05, 2023

Good Morning and thanks for the reply,
my exact code is:

var names = this.getField("GC_Team").valueAsString;

this.getField("Attention:").setItems(names.split("\r"));

 

Field name "GC_Team" is populated by my FDF file, output from a separate PDF form.

Field name "Attention:" is the dropdown box that includes the above javascript. The javascript is triggered by an "On Focus" mouse action associated with the "Attention:" field.

Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2023 Jun 05, 2023

This is not a good setup. You should use the Validation script of the text field to populate the drop-down.

Also, you need to examine the value of the text field after importing it. Maybe it doesn't use the regular line breaks that are used when you manually enter the text ("\r"), but something like "\n" or even "\r\n".

To do that run this code from the Console:

this.getField("GC_Team").valueAsString.toSource();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2023 Jun 05, 2023

I just confirmed via the console that field name "GC_Team" is a single line of first and last names, without line breaks. My challenge is to re-format these such that the drop down offers names on separate lines.
Can the prior snippet of code be used verbatim as a validation script of the text field "GC_Team"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2023 Jun 05, 2023

omigosh - firstly, my humblest apologies...
textbox "GC_Team" merely needed to be formatted to include "Multiline". the javascript, as previously organized is working. That due diligence was an error on my part.

my sincere thanks for your help tho thus far. Immeasurable.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2023 Jun 05, 2023

I am highly motivated to learn more how to re-arrange my scripting per your suggestion: to use a Validation Script at the Textbox "GC_Team".. how would you instruct to do this (per my prior query)?
Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2023 Jun 05, 2023
LATEST

Just change this line:

var names = this.getField("GC_Team").valueAsString;

To this:

var names = event.value;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines