dependent dropdown; same code - different form

New Here ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Hello-  I have 1 dropdown (Vertical Market) with multiple selections that I would like to control my second drop down (Sub Category List).  I was able to get the code to work on one form, so I copied the javascript from the vertical market/format tab/custom/custom keystroke script.  Accessed a second form which already had a drop down for Vertical Market but sub category was a plain taxt field, so I deleted that, added in a drop down field with with same name Sub Category List, saved the form. Now I'm getting nothing in the second dropdown Sub Category List to choose from.   I have reviewed and compared the code to make sure I didn't miss something on the copy paste and it seems everything is identical.  Here is a bit of the code I'm using

var f = this.getField("Sub Category list");

switch(event.value)
{
case "Aerospace":
f.setItems(["-Select a Sub Category-",
"Air/Filtration",
"Battery",
"Electronics",
"Enclosure",
"Engine",
"Fuel System",
"Hydraulics",
"Valves"]);
break;
case "Automotive":
f.setItems(["-Select a Sub Category-",
"Air Intake",
"Brake Systems",
"Coolant Systems",
"Electrical Connectors",
"Enclosure",
"Engine",
"Engine Component",
"Exhaust",
"Fuel System",
"HVAC",
"Lighting",
"Safety Systems",
"Steering",
"Suspension",
"Oil Component",
"Transmission"]);
break;
case "Consumer Electronics":
f.setItems(["-Select a Sub Category-",
"Cell Phone",
"Modem/Router",
"Other",
"Printer",
"Tablet",
"Two-way Radio",
"Wearable Device"]);
break; 

default:
f.setItems([]);
break;

}

I would prefer to be able to copy paste as my code is quite lengthy as there are more beyound the last shown, for the sake of project completion and I need these 2 field to be identical on 13 separate forms.

Any additional help, comments, assistance will be greatly appreciated.

Thank you!

Views

39

Likes

Translate

Translate

Report

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

correct answers 2 Correct answers

Community Expert , Sep 20, 2022 Sep 20, 2022

When you say on separate forms, are you referring on separate pages in the same PDF document or separate form fields, or actual separate PDF documents that will be opened in separate tabs and will be populating data from one Vertical Market dropdown in PDF form A (for example) to  "Sub Category List" dropdown field in PDF form B?

 

++EDITED REPLY

 

In any case, I tested the same script and it worked on my end

 

You may need to check that "Sub Category list" , just as it appears spelled in your s

...

Likes

Translate

Translate
Community Expert , Sep 20, 2022 Sep 20, 2022

Make sure your field is named properly, in your text you named field "Sub Category List" and in your script you used "Sub Category list".

Also change this line:

f.setItems([]);

to this:

f.clearItems();

Likes

Translate

Translate
Community Expert ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

When you say on separate forms, are you referring on separate pages in the same PDF document or separate form fields, or actual separate PDF documents that will be opened in separate tabs and will be populating data from one Vertical Market dropdown in PDF form A (for example) to  "Sub Category List" dropdown field in PDF form B?

 

++EDITED REPLY

 

In any case, I tested the same script and it worked on my end

 

You may need to check that "Sub Category list" , just as it appears spelled in your script,  is spelled in the same way for the name of the dropdown field that you created; instead of  "Sub Category List", for example.

 

See if mispelling the combobox field name was the issue.

Likes

Translate

Translate

Report

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 ,
Sep 21, 2022 Sep 21, 2022

Copy link to clipboard

Copied

LATEST

yes, that was corrected and all worked out.  thank you so much for your eyes and help with this, it has truly been a life saver.

Likes

Translate

Translate

Report

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 ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Make sure your field is named properly, in your text you named field "Sub Category List" and in your script you used "Sub Category list".

Also change this line:

f.setItems([]);

to this:

f.clearItems();

Likes

Translate

Translate

Report

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 ,
Sep 21, 2022 Sep 21, 2022

Copy link to clipboard

Copied

Thank you so much!  After looking at this for so long I totally missed the lower case L which fixed it!

I appreciate your eyes, and willingness to help a stranger which made my day!

Thank you again!

Likes

Translate

Translate

Report

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 ,
Sep 21, 2022 Sep 21, 2022

Copy link to clipboard

Copied

Totally different PDF documents.  Individual forms that are used for specific orders but those 2 fields are consistent on all 13 individual PDFs.

Likes

Translate

Translate

Report

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