Moving to the next item in a list

Hi Everyone,

Little bit stuck on something in my app and can’t seem to find an answer.

My app lets users decide which question is currently shown to all users by setting an ‘ActiveQuestion’ value on a page.

The ‘ActiveQuestions’ come from a list of things attached to the page.

Right now, the only way for users to change the ‘ActiveQuestion’ is to select one from a dropdown, which then makes the change in the database.

I would really like to just have buttons for ‘Next Question’ which automatically sets ‘ActiveQuestion’ to the next value in the list.

Here’s a couple of screenshots, would be great if anyone has any ideas!

Thanks, James.

Hey James,

There are a number of ways you could go about doing this. One good thing to study up on would be custom states. You could, for example, set two custom states on any element on the screen. One custom state could be called “active question #”, and it could be a number that is set to 1 by default. The other custom state could be called “active question” that is of the type question. Then, when a user clicks on a “Next Question” button, you could increase the “active question #” by 1, and change “active question” to be the question item from your list of questions that corresponds to “active question #”. (It would be something like List of questions: item #active question #'s number. You’re essentially picking one item from your list of questions, and that item’s index corresponds to the “active question #” custom state. Hope this helps! Let me know if you’re confused.

1 Like

Thanks very much for the tips, I haven’t used custom states before so I will look into that and see if I can get it to work with that!

This topic was automatically closed after 70 days. New replies are no longer allowed.