How to refer to the items in a dropdown list?

Explorer ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Hi everyone,

 

I am creating a dropdown menu, that contains answers to a questionaire. 

Depending on the answer, a dialog box will pop up.

I need to refer to each item in the dropdown menu.

I read somewhere that each item in a dropdown menu has a number that can be referred to.

So, how do I refer to that number, so that I can trigger the correspondent dialogbox?

 

Thanks a lot for you reply in advance.

TOPICS
Create PDFs, How to, JavaScript, PDF forms

Views

53

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 1 Correct Answer

Adobe Community Professional , Mar 26, 2021 Mar 26, 2021
You are missing = at this line 'if (resposta = [0]) {'it should be:if (resposta == [0]) {

Likes

Translate

Translate
Adobe Community Professional ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

If you want to get number at which specific item is, then use "currentValueIndices"
if you want to get item at specific number then you can use "getItemAt()".
numbers starts from 0,1,2...etc so first item is 0, second item is 1...etc

 

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
Explorer ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Thanks a lot for your answer.

 

I understand it is possible to create a script using an IF clause in the Actions section of the dropdown menu,

to check the option selected and then trigger the dialog box.

In case yes, which trigger option should I select in the Actions section to release the dialog box? (for instance, On Focus).

 

 

 

 

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
Explorer ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

I wrote the following code, but it keeps showing me only one dialog box (right answer), even when

I chosse a different option in the dropdown list.

 

var n = this.getField("Dropdown24");
var resposta = n.currentValueIndices;
if (resposta = [0]) {

app.alert("Correct answer. Congratulations!", 3,0)

}

else if (resposta != [0]){

app.alert("Incorrect answer.")

}

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
Adobe Community Professional ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

You are missing = at this line 'if (resposta = [0]) {'

it should be:

if (resposta == [0]) {

 

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
Explorer ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

LATEST

Thanks a lot! Now it worked. 

 

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