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

How to cycle through Dropbox items using a button

New Here ,
Nov 18, 2021 Nov 18, 2021

Hello,

I'm am still very new to coding in general, so the following issue is pretty much due to inexperience and lack of coding knowledge. What I am trying to do is cycle through the items inside of a dropdown box using a button. The plan was to have 2 buttons, one for cycling up through the items and one to cycle down, the dropbox would consist of numbers and I would simply click one of the 2 buttons "up" or "down" inorder to get the corresponding number in the list. Would this be possible through javascript? If so, how would I go about doing so?

I've been soaking up all kinds of coding information, however I haven't figured out the code value for the items inside of the Dropbox inorder to tell the buttons to cycle through the list/values

TOPICS
How to , JavaScript
462
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 18, 2021 Nov 18, 2021

Hi,

 

that's quite easy to do. Given your drop down is named DDL it ca be don this way:

// Select lower drop down item
var d = this.getField("DDL"),
    i = d.currentValueIndices;

if (i > 0) {
    d.currentValueIndices = i - 1;
}

 

// Select upper drop down item
var d = this.getField("DDL"),
    i = d.currentValueIndices,
    n = d.numItems;

if (i < n-1) {
    d.currentValueIndices = i + 1;
}

 

View solution in original post

Translate
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 ,
Nov 18, 2021 Nov 18, 2021

Hi,

 

that's quite easy to do. Given your drop down is named DDL it ca be don this way:

// Select lower drop down item
var d = this.getField("DDL"),
    i = d.currentValueIndices;

if (i > 0) {
    d.currentValueIndices = i - 1;
}

 

// Select upper drop down item
var d = this.getField("DDL"),
    i = d.currentValueIndices,
    n = d.numItems;

if (i < n-1) {
    d.currentValueIndices = i + 1;
}

 

Translate
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
New Here ,
Nov 18, 2021 Nov 18, 2021
LATEST

Thank you very much!

Translate
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