This is an old revision of the document!
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.
'next'
– Next button'back'
– Back button
Note: The function buttonCode()
only generates the HTML code for the button. The code still has to be embedded in the questionnaire page using html()
or placeholders.
Note: After the function has been called up, the automatic insertion of the buttons at the end of the current page is prevented.
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 Questionnaire Layouts.
$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(' <table cellspacing="10" cellpadding="0"> <colgroup> <col width="60%"> <col width="40%"> </colgroup> <tr> <td>Press this button to go to the next page →</td> <td>'.$buttonNext.'</td> </tr> <tr> <td>To go back to the previous page, press this button →</td> <td>'.$buttonBack.'</td> </tr> </table> ');
$buttonNext = buttonCode('next'); // Saves the HTML code for the $buttonBack = buttonCode('back'); // buttons in two variables replace('%btnNext%', $buttonNext); // Store for placeholders replace('%btnBack%', $buttonBack); 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.
<table cellspacing="10" cellpadding="0"> <colgroup> <col width="60%"> <col width="40%"> </colgroup> <tr> <td>Press this button, to go to the next page →</td> <td>%btnNext%</td> </tr> <tr> <td>To go back to the previous page, press this button →</td> <td>%btnBack%</td> </tr> </table>
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.