Changing group title via javascript

More
1 month 1 week ago #159374 by jkautto
jkautto created the topic: Changing group title via javascript
Hi

I want to add progress information into the group title, i.e., group title should say something like ''this is page 6 out of 24''. This should be simple, but I don't know the correct javascript commands to do it.
I have tried this code without luck (nothing happens):
<script type='text/javascript'>
   $(document).ready(function() {
       var N_total = {NUMBEROFGROUPS};
       var N_current = $("#thisstep").val();
       $(".grouptitle").text("this is page " + N_current + " out of " + N_total);
});
</script>

Code is in group description (same for each group). I have version 2.70. Can someone help?

Please Log in to join the conversation.

More
1 month 1 week ago #159387 by fvanderstarre
fvanderstarre replied the topic: Changing group title via javascript
Since your message seems to be fixed for each group, why not put it directly in the group title without using any script or variables?
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

More
1 month 1 week ago - 1 month 1 week ago #159390 by jkautto
jkautto replied the topic: Changing group title via javascript
Title should tell the current page with group randomization enabled, hence it cannot be fixed. Group title should work like the progress bar with page numbers instead of percentages. I already changed the progress bar to show step information (format "step 5 out of 57" etc.) via javascript, but I also want to include this information in titles.

PS. Without group randomization, I would not need scripting (I could fix titles when creating the survey). You are correct there.
Last Edit: 1 month 1 week ago by jkautto. Reason: text improvements

Please Log in to join the conversation.

More
1 month 1 week ago - 1 month 1 week ago #159402 by tpartner
tpartner replied the topic: Changing group title via javascript
What template are you using and where did you find the selector ".grouptitle"?

I find that this works with the default template:

<script type='text/javascript'>
	$(document).ready(function() {
		var N_total = {NUMBEROFGROUPS};
		var N_current = $("#thisstep").val();
		$(".group-name").text("This is page " + N_current + " out of " + N_total);
		$(".group-description-container").hide();
	});
</script>


Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last Edit: 1 month 1 week ago by tpartner.
The following user(s) said Thank You: jkautto

Please Log in to join the conversation.

More
1 month 1 week ago #159411 by jkautto
jkautto replied the topic: Changing group title via javascript
Thanks, your code works perfectly! It also seem to work without the last command, i.e., "$(".group-description-container").hide();".

I found ".grouptitle" from this thread:

www.limesurvey.org/forum/can-i-do-this-w...ion-group-in-tempate

Please Log in to join the conversation.

More
1 month 1 week ago #159415 by jkautto
jkautto replied the topic: Changing group title via javascript
addition: My template is "news_paper" with few minor modifications.

Please Log in to join the conversation.

More
1 month 1 week ago #159433 by DenisChenu
DenisChenu replied the topic: Changing group title via javascript
We didn't add {STEP} in core Expression Manager ? Must be done …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!