How to get index out of fixed 1x1 Repeating group

I am building a simple survey tool where each question is on a single page, therefore, repeating group is fixed 1x1. I would like to display the index number ie “Question x of y” but it appears that index always remains at 1. The y is easy to get since access repeating group :count. The next issue will be on the NEXT button which needs to detect that survey has reached end of questions ie index=count. Can anybody help?

Hi,
The first ideas that came to my mind:

  • storing some information in the current user field of your choice (eg. currentQuestion, totalQuestions) and filling them appropriately (eg. increasing by 1 when user clicks Next question until current=total then saving/doing whatever you need)
  • passing additional parameters to the page; currentquestion (can be named shorter) and on page load/clicking next - comparing with :count of RG or search result for questions / adding 1 when still more questions available. This one just passes variable, so no need to add any fields to the database.

Does your page really reload or it’s just changing contents of the RG? If just contents - you could keep the currentquestion as the state of the page or RG or any other element.

Hope that helps or brings some other concepts.

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