Skip to main content
Participating Frequently
January 30, 2019
Answered

Dropdown Help!!!

  • January 30, 2019
  • 1 reply
  • 1244 views

I have created a dropdown that is pulling from 2 hidden fields. Problem is when I select the the second item in the list and tab, it automatically goes back to the first item in the list. I am using the following javascript:

var f1 = getField("PRIMARY_PERSON_LAST_COMMA_SPACE_FIRST_SPACE_MI").valueAsString;

var dropdown = getField('Dropdown1');

var f2 = getField("SHARE_1_SH_PERSON_LINK_1_PERSON_SERIAL_DESCRIPTION").valueAsString;

dropdown.setItems([f1,f2]);

Please help!!!

This topic has been closed for replies.
Correct answer try67

My apologies for not being clear in my initial post.

This is my dropdown and when I select Paul it defaults back to Abigail when I tab to the next field in my form. I would like it to stay on Paul. I hope this clears things up. Thanks for all your help!


Move the code to the validation event, and change this line:

var oldValue = event.target.value;

To:

var oldValue = event.value;

1 reply

try67
Community Expert
Community Expert
January 30, 2019

Where did you place this code?

sww5275Author
Participating Frequently
January 30, 2019

Under the Calculate tab in the Custom calculation script.

try67
Community Expert
Community Expert
January 30, 2019

That means that each time any field in the file is changed the values get re-applied, and the field is reset to the default value (the first one in the list). To overcome that you need to save the current value before applying the list, and then re-apply it afterwards.

You need to take into account the possibility that that value is no longer available, though.