Skip to main content
Ryan_Oliver_02445
Known Participant
Jan 30, 2019 8:41 PM UTC
Answered

How to select values in a Drop down box within JS

Good evening, I am attempting to access a drop down list, however,  I can't seem to change the value of the Drop down box within JS.  Here is my code:

       var ListOne = this.getField("relationship.0");

       var search = ListOne.getItemAt[1];

       console.println(search.value);

I can print out the current value that's set in the drop down list, but I can't set it to, "Mother" or, "Brother."

Any help would be greatly appreciated!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Jan 30, 2019 8:46 PM UTC

Your code contains multiple errors, but at any rate you can't set the value of a specific item in the list, only the entire list as a whole, using the setItems method.

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Jan 30, 2019 8:46 PM UTC

Your code contains multiple errors, but at any rate you can't set the value of a specific item in the list, only the entire list as a whole, using the setItems method.

Translate
Ryan_Oliver_02445
Known Participant
Jan 30, 2019 8:50 PM UTC

Works grand now, here is an example of the code that works as intended:

var ListOne = this.getField("relationship.0");

ListOne.setItems(["Brother from another Mother"]);

console.println(ListOne.value);

Simple as that, thank you.

Translate