Back button customization -- pagination

141 views
Skip to first unread message

Arne Holverscheid

unread,
Jan 16, 2023, 10:30:25 AM1/16/23
to formr
Hi all,

I have a survey for which I would like it to be possible to move back to the previous page via a back button. I have enabled pagination and can now navigate back to any previous page. However, I would ideally like to: 

1. Only allow going strictly just back -- so if you click the back button, you go the page immediately preceding the current one

2. I would like to move the back button and customize it. 

Is there any way to do this? I am not super familiar with html and java script but would be happy to figure this out if needed. However, I wouldn't even now where and how to start with this. 

Thank you!

Nico B

unread,
Jan 18, 2023, 4:40:05 PM1/18/23
to formr
Very exited to hear if anyone has a proper solution for this, because mine is more of a bodge.
To make only the button for the previous page accessible, add the following code to the JS-part of your Run:

window.onload = (event) => {

    var navigation = document.getElementsByClassName("page-buttons")[0];
    var previous_page = navigation.lastElementChild;
   
    for(var i = 0; i < navigation.childNodes.length; i++){
        if(previous_page!=navigation.childNodes[i]){
            navigation.childNodes[i].style = "display: none;";
        }
    }
  // previous_page.style = "" and  previous_page.innerText = ""
}

A short explanation:
Using the inspector (usually to found in your browsers developer tools), you can identify the classNames, Names or IDs of the elements that interest you.
Having obtained any of these, you can manipulate the element using CSS (if you have the elements id or name or if the element you're interested in is the only one in this class) or JS.
This case is somewhat special as you need window.onload to ensure your code is executed after the navigation has rendered.
Using JS (and CSS) you can now change the properties of the remaining button.

I need to stress again that this is a hotfix, not least because the changes only apply after the page has fully loaded, meaning all buttons will be visible for a short period of time.
Reply all
Reply to author
Forward
0 new messages