Skip to main content
first.officer
Inspiring
August 29, 2024
Answered

Dependent drop down - not allowing selection of set.Items

  • August 29, 2024
  • 2 replies
  • 666 views

A while since I've posted, in fact since I've done anything with PDF's, so have forgotten most things, apologies in advance, for what is most likely a very basic error or misconception.....

 

Have an issue with dependent drop-downs (see attached example) in as much as when selecting an option from the list in the "DelayCodeCategory" field drop-down, it successfully gives the required options in the "Items" field drop-down, but when trying to select any given option shown, as soon as you leave ("tab out of") the field - it deletes the chosen option!! I can't see what is at error here?. I should add that I have only added JS for the first three selectable options of the "DelayCodeCategory" field drop-down as an example.

 

 

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

Try like this:

var f = this.getField("Items");
if (event.source && (event.source.name==event.target.name)){
switch(event.value)
{
case "Please select delay code category....":
f.setItems([""]);
break;
case "BAG":
f.setItems(["","AAA","BBB","CCC"]);
break;
case "COM":
f.setItems(["","111","222","333","444"]);
break;

default:
f.clearItems();
break; 
}}

 

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 29, 2024

Try like this:

var f = this.getField("Items");
if (event.source && (event.source.name==event.target.name)){
switch(event.value)
{
case "Please select delay code category....":
f.setItems([""]);
break;
case "BAG":
f.setItems(["","AAA","BBB","CCC"]);
break;
case "COM":
f.setItems(["","111","222","333","444"]);
break;

default:
f.clearItems();
break; 
}}

 

PDF Automation Station
Community Expert
Community Expert
August 29, 2024

Nice work!

PDF Automation Station
Community Expert
Community Expert
August 29, 2024

It is the clearItems portion of your script.  When you tab out of the field the dropdown value is commited, which means the calculation runs again and clears the items.

first.officer
Inspiring
August 29, 2024

Thnaks for the reply....I did think it might be that, but it's not - removing the clearitems potion still doesn't resolve the issue.