• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to refer to the items in a dropdown list?

Participant ,
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

517

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

Community Expert , Mar 26, 2021 Mar 26, 2021

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

it should be:

if (resposta == [0]) {

 

Votes

Translate

Translate
Community Expert ,
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

 

Votes

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
Participant ,
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).

 

 

 

 

Votes

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
Participant ,
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.")

}

Votes

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 ,
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]) {

 

Votes

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

Copy link to clipboard

Copied

LATEST

Thanks a lot! Now it worked. 

 

Votes

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