====== Timer: Show the 'Next' Button After a Certain Period of Time ====== This chapter describes how the Next and Back buttons on a questionnaire page can be manipulated so that they do not appear until after a given amount of time. In principle, any content can be displayed after a certain period of time by using this solution. This solution (like most dynamic content) is based on [[:en:create:javascript|JavaScript]] and has the following restrictions: * This does not work if a participant has specifically disabled JavaScript. In order for the participant to still be able to partake, the script is designed in a such a way that means the Next button appears as usual. * If the participant reloads the page (F5 button, //refresh// or //reload//), or returns to the page by clicking on the Back button, the timer starts from the beginning. The Back button can be disabled on the current and/or next page by using the PHP function ''[[:en:create:functions:option|option()]]'' ===== Feature ===== - If the page is loaded, the Next button is hidden by JavaScript. - Afterwards, a timer starts which displays the button again after a certain period of time. ===== Implementation ===== Only a text element with the following content (created in **Text Elements and Labels**, //Display// as "HTML code") is required. This text elements is dragged into the respective questionnaire page when composing the questionnaire. **Note:** This JavaScript code makes use of the SoSci Survey specific function ''SoSciTools.submitButtonsHide()'' to hide all buttons. You may specifically identify the submit button via ''%%document.getElementById("submit0")%%'' and change it's attribute ''.style.display'' to ''%%"none"%%''. For having the button re-appear, it may be necessary to write an additional function that restores the attribute to the empty string ''%%.style.display = ""%%''. ===== Show Other Content ===== In the JavaScript code you can see the ID (HTML ID) ''buttonsAuto''. This ID is assigned automatically to the buttons which appear at the bottom of the questionnaire page - whether just a Next button is there, or a Back button as well. If you specify a different HTML ID, other objects on the page will be displayed and hidden. If your content does not have an HTML ID yet, you can just put a ''
'' tag around it:

Heading

You can read the secret text here.

Instead of text, you can also place a text element, a question, or other content inbetween the ''
'' tags. To do this, you just have to use two HTML elements before and after the respective content in the questionnaire:
**Tip:** This is not necessary for questions because they already have an HTML ID ([[:en:create:dynamic|Immediately Show Questions when a Certain Option is Selected]]). The HTML/JavaScript code that takes care of hiding would look like this: ===== Placeholder for the Button ===== With this solution, the layout is slightly altered when the button appears -- the page gets bigger. If you do not want this, you can hide the content with the CSS attribute ''visibility'', instead of with ''display'': ===== Display Countdown ===== It may be irritation for respondents if the "next" button is missing. Therefore, it may be useful to display a countdown instead. Use the following HTML/JavaScript code to do so: