Return to Table of Contents after each block in the Table? | XM Community
Solved

Return to Table of Contents after each block in the Table?


Userlevel 2
Badge +2
I have a TOC that has several blocks. Once users start with any block, it just seems to keep going through all the blocks. Is there any way to make users return to the TOC after they finish each block?

Thanks
icon

Best answer by NiC 15 April 2019, 10:14

View original

14 replies

Userlevel 7
Badge +27
@treimt,

I think the easiest way to do this is to create a "TOC separator" block that contains a single descriptive text question with JS that clicks the JumpButton. Add the block after each of the other TOC blocks in your survey flow.
Userlevel 7
Badge +27
Hi @treimt,

We can surely do this.
1. So firstly we will need the TOC button.
2. Now if we want the respondents of last Question in a block to be transported to TOC page you can add the following code as shown in the image given below :
jQuery("#NextButton").unbind("click");
jQuery("#NextButton").click(function() {jQuery("#JumpButton").click() });
!

Important - This code should be added on one of the questions on the last page.

3. Now if we need hide the TOC button , you can add the custom CSS in the Look & Feel Section
This would be the custom CSS:
#JumpButton{
visibility:hidden;
}
Userlevel 7
Badge +27
> @baxybaxy68 said:
> Aha.
> Many thanks for your quick response!
>
> I'll try your solution instead. But how am I going to prevent the names of those 'separator' blocks from appear in the TOC?

You can hide them in the TOC with JS that you put in the TOC library message. It has been a long time since I needed to do this, so the code I have is prototypejs where the name of the block is toc_sep:
```
var toctexts = $$('.TocText');
for(var i=0;i<toctexts.length;i++) {
var toctext = toctexts[i];
if(toctext.innerHTML == "toc_sep") {
$(toctext).up().up().hide();
}
}
```
Userlevel 7
Badge +27

In the toc_sep question, just click the Jump Button:
Qualtrics.SurveyEngine.addOnReady(function() {
jQuery("#JumpButton").click();
});

Userlevel 7
Badge +27

Once you've completed all the blocks, only the top_sep block is left as incomplete. You can count the number of completed blocks and store it in an embedded variable then click the Next button in toc_sep when you have competed all the blocks. Say you have 5 blocks.
Count completed blocks in your TOC library message:
Qualtrics.SurveyEngine.setEmbeddedData("completeBlocks",jQuery("li.Complete").length);
In toc_sep:
if(parseInt("${e://Field/completeBlocks}") < 5) jQuery("#JumpButton").click();
else jQuery("#NextButton").click();
If you don't want to go back to the TOC after the last block is completed, change 5 to 4.


Userlevel 7
Badge +27

https://www.qualtrics.com/community/discussion/comment/36650#Comment_36650You have to put JS in a

Scanning file for viruses.

Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.

OK

This file cannot be downloaded

Sorry, our virus scanner detected that this file isn't safe to download.

OK