Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Get the number of questions on the current page

  • RautenkinG
  • RautenkinG's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 8 months ago #157852 by RautenkinG
Hey Guys,

quick question.

On my page i have four 5 star rating question. They appears if on the previous sites their checkboxes are checked.

Since i have something like this before evry quesiton "1) .... 1.1) .... 2) ...." I wish i could do it with them aswell, but since i never know how many of them will appear i wont know which number i should give them.

Is there a .js solution for it which counts how many question on this page appears so i can use this to set the "x.y)" number of the question with it?

Greetings
Steffen
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 8 months ago - 6 years 8 months ago #157858 by tpartner
1) Insert a span element into the text of every question something like this:

Code:
2.<span class="q-number"></span>) Some question text...


2) Place this script in the source of the first question:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('.question-container:visible').each(function(i) {
      $('.q-number', this).text(i+1);
    });
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 8 months ago by tpartner.
The topic has been locked.
  • RautenkinG
  • RautenkinG's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 8 months ago #157859 by RautenkinG
Replied by RautenkinG on topic Get the number of questions on the current page
worked perfectly, ty very much!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose