Welcome to the LimeSurvey Community Forum

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

Getting current page number for use in js

More
2 weeks 6 days ago #274628 by BBSR-SR5
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Cloud Version 6.17.10
Own server or LimeSurvey hosting: LS cloud
Survey theme/template: fruity 23 customisation
==================
Hi,

I'm trying to write a js that basically wants to check the current page num against two other numbers and does something in case true.
Code:
if x <= current_page &amp; current_page < y {
do stuff;
}
Is the number of the current page exposed somewhere? (like in the html?)

Thanks a lot :)

Please Log in to join the conversation.

More
2 weeks 6 days ago #274629 by holch
As Limesurvey doesn't have a "page" concept, I don't think you'll be able to get this information.

So, you have to go either with "question" or "questiongroup", depending on how you display your questionnaire.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

More
2 weeks 6 days ago #274631 by BBSR-SR5
Hm that's a bit strange. The Index navigation menu has this sort of move=number thing in its links:
Code:
<a href="/163199?move=2" data-limesurvey-submit="{ &amp;quot;move&amp;quot;:2 }" class="dropdown-item  ">
                            1.2. Kommunen im Strukturwandel
                        </a>
So there does seem to be some sort of page numeration in the background?
I was hoping I could get the current one, so I could just color the link with js.

(Basically I made a custom sidenav for a survey that just jumps to the start of a group of questions (by content, not limesurvey), and now people want the group of questions marked in the sidenav.

Please Log in to join the conversation.

More
2 weeks 6 days ago #274632 by Joffm
Can't you use the "qseq" resp. "gseq" property?
How do you display?
Group by group? Question by question?

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
2 weeks 6 days ago #274633 by holch
I am not sure how this move=2 works. Because I think it depends on the way you display your questions.

You would have to dig deeper into how the side navigation works. Maybe Denis has some insights.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

More
2 weeks 6 days ago #274634 by BBSR-SR5
I'm using group by group. I do have index and backwards navigation enabled.

I did something really quick and dirty (which works by just reading the currently disabled move command out of the index dropdown:
Code:
// Get current page
    $('header ul.dropdown-menu li.index-item a').each(function(){
        if ($(this).hasClass('disabled')){
            var myHref = $(this).attr('href');
            var pagenum = Number(myHref.split("=")[1].trim())
            console.log(pagenum);
        }
        
    });

I can work with that. What did I do, I did hack a nav menu into the outerframe.twig

It just displays the groups which end with "#" in their grouplabel
Code:
<!-- outer frame container -->
<div class="{{ aSurveyInfo.class.outerframe }} container-fluid"
     id="{{ aSurveyInfo.id.outerframe }}" {{ aSurveyInfo.attr.outerframe }} >
    <div class="row">
        <div class="col-left col-xl-2">
            {% if (aSurveyInfo.aQuestionIndex.bShow == true) %}
                {% if (not aSurveyInfo.popupPreview) and aNavigator.aMoveNext.value == "movesubmit" %}
                {# Do nothing - this exists as a bugfix to hide Navigator on fake lastpage #}
                {% else %}
 
                    <div id="customNavMenu" class="row space-col list-group">
                        <div class ="list-group-item sidenavborder"><b>Navigationsmenü</b></div>
                        {% for step, indexItem in aSurveyInfo.aQuestionIndex.items %}
                            {% if '#' in indexItem.text %}
                                {% set statusClass = '' %}
                                {% if attribute(indexItem.stepStatus, 'index-item-unanswered') is defined and attribute(indexItem.stepStatus, 'index-item-unanswered') == true %}
                                    {% set statusClass = statusClass ~ ' index-warning' %}
                                {% endif %}
                                {% if attribute(indexItem.stepStatus, 'index-item-error') is defined and attribute(indexItem.stepStatus, 'index-item-error') == true %}
                                    {% set statusClass = statusClass ~ ' index-danger' %}
                                {% endif %}
                                {% if attribute(indexItem.stepStatus, 'index-item-current') is defined and attribute(indexItem.stepStatus, 'index-item-current') == true %}
                                    {% set statusClass = statusClass ~  ' disabled' %}
                                {% endif %}
                                <div class="list-group-item sidenavborder {{ indexItem.coreClass }}">
                                    <a href='{{ indexItem.url }}' data-limesurvey-submit='{{ indexItem.submit }}'
                                       class='dropdown-item sidenav {{ statusClass }}'>
                                        {{ indexItem.text|split('#')[0] }}
                                    </a>
                                </div>
                            {% endif %}
                        {% endfor %}
                    </div>
                {% endif %}
            {% endif %}
        </div>
        <div class="col-left col-xl-8">
            {# Which file to include for content is decided inside the layout #}
            {% include './subviews/content/mainrow.twig' with {'include_content': include_content } %}
        </div>
    </div>
</div>
 
 

Please Log in to join the conversation.

Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose