====== buttonCode() ====== ''string **buttonCode**(string //buttonID//)'' The HTML code which displays a Next or Back button is generated with ''buttonCode()''. Normally, a Next button and (depending on the settings) also a Back button are displayed at the end of every questionnaire page. This function assists in repositioning these buttons. * //buttonID//\\ The button for which the HTML code should be generated -- there are 2 options available: * ''%%'next'%%'' -- Next button * ''%%'back'%%'' -- Back button * ''%%'break'%%'' -- Button to interrupt the interview * ''%%'leave'%%'' -- Button to cancel and delete data ===== Tips ===== **Note:** The function ''buttonCode()'' only generates the HTML code for the button. The code still has to be embedded in the questionnaire page using ''[[:en:create:functions:html|html()]]'' or [[:en:create:placeholders|placeholders.]] **Note:** After the function has been called up, buttons can no longer be inserted automatically. **Tip:** If you want to reposition the buttons in general, modify the questionnaire layout and use the placeholders ''%button.next%'' and ''%button.back%'' in the HTML template of the layout, as described in the guide to [[:en:create:layout|Questionnaire Layouts]]. ===== Example: Next button in the middle of the questionnaire page ===== html( '
'. buttonCode('next'). '
' );
===== Example: Insert Directly in HTML Code ===== $buttonNext = buttonCode('next'); // saves the HTML code for the $buttonBack = buttonCode('back'); // buttons in 2 variables // Insertion of the HTML codes into the questionnaire, e.g. in a table html('
Press this button to go to the next page → '.$buttonNext.'
To go back to the previous page, press this button → '.$buttonBack.'
');
===== Example: Use with Placeholders ===== $buttonNext = buttonCode('next'); // Saves the HTML code for the $buttonBack = buttonCode('back'); // buttons in two variables replace('%btnNext%', $buttonNext, 'html'); // Store for placeholders replace('%btnBack%', $buttonBack, 'html'); text('buttons'); // display text in the questionnaire In order for the above PHP code to work correctly, another text element with the ID "buttons" and the following content must be created in **Text Elements and Labels**.
Press this button, to go to the next page → %btnNext%
To go back to the previous page, press this button → %btnBack%
In principle, the placeholders, as well as the text, could easily be integrated onto other pages. However, the default buttons are only hidden on the page on which ''buttonCode()'' is called up.