Get the number of questions on the current page

More
5 months 3 weeks ago #157852 by RautenkinG
RautenkinG created the topic: Get the number of questions on the current page
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

Please Log in to join the conversation.

More
5 months 3 weeks ago - 5 months 3 weeks ago #157858 by tpartner
tpartner replied the topic: Get the number of questions on the current page
1) Insert a span element into the text of every question something like this:

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


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

<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: 5 months 3 weeks ago by tpartner.

Please Log in to join the conversation.

More
5 months 3 weeks ago #157859 by RautenkinG
RautenkinG replied the topic: Get the number of questions on the current page
worked perfectly, ty very much!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!