====== Navigation in the Questionnaire ====== Usually, respondents start on the first page and then fill out the questionnaire sequentially. Sometimes the sequence is changed by ''[[:en:create:functions:setpageorder]]'' or ''[[:en:create:functions:gotopage]]'', but even then the respondents follow the sequence specified by the project manager. This manual describes how to add a menu or navigation to the questionnaire, so that respondents can jump between the pages/sections as they like. This is particularly useful if a form in SoSci Survey is used to collect information (see also [[:en:create:mix-forms]]). {{:de:create:scr.navigation.result1.png?nolink|Example of a navigation menu in the questionnaire}} ===== Basics ===== In the first step, [[:en:create:pageid|page IDs]] are entered under **Compose Questionnaire** for all pages that the respondent shall be able to jump to. The title of the page is entered as //Note//. {{:de:create:scr.navigation.pageid.png?nolink|Entering page ID and note}} The actual navigation buttons are generated by the function ''[[:en:create:functions:buttontopage]]''. This function creates HTML code, which can be included in the questionnaire page by means of ''[[:en:create:functions:html]]''. With the following PHP code, buttons to different pages would be offered on a questionnaire page. html( '
'. buttonToPage('start'). buttonToPage('contact'). buttonToPage('study'). buttonToPage('services'). buttonToPage('documents'). buttonToPage('notes'). buttonToPage('submit'). '
' );
{{:de:create:scr.navigation.result2.png?nolink|Buttons for navigating between different pages}} This PHP code would now have to be inserted on each individual page of the questionnaire (e.g., at the top of the page). Of course, this is impractical and makes subsequent changes more difficult. Therefore, a new function is defined under **Compose Questionnaire** in the tab //PHP Functions//, which takes care of the navigation and possibly further adjustments. function navigation() { // Navigation html( '
'. buttonToPage('start'). buttonToPage('contact'). buttonToPage('study'). buttonToPage('services'). buttonToPage('documents'). buttonToPage('notes'). buttonToPage('submit'). '
' ); // Label of the next button option('nextbutton', 'Next form'); }
To use the function, the following PHP code is then required on each page of the questionnaire: navigation(); ===== Customizing the Layout ===== The arrangement on the page and the appearance of the buttons can be customized by means of CSS. First, some additions are made to the HTML code: * In the outer ''
'' block element, a gray border (''border'') at the top and bottom is added with the ''style'' attribute, * another ''
'' block element with a CSS class (in the example "NavButtons") is added around the buttons. The additional class ''s2flex'' allows using the full width. * An empty ''
'' element is added between the buttons for "notes" and "submit" to create some space between the buttons. html( '
'. ''. '
' );
To match this, CSS statements are added in the [[:en:create:layout|questionnaire layout]] in the **HTML template** within the ''