SoSci Survey
This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:
 

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

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 html() or 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 Questionnaire Layouts.

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('
  <table cellspacing="10" cellpadding="0">
  <colgroup>
    <col width="60%">
    <col width="40%">
  </colgroup>
  <tr>
    <td>Press this button
        to go to the next page &rarr;</td>
    <td>'.$buttonNext.'</td>
  </tr>
  <tr>
    <td>To go back to the previous page,
        press this button &rarr;</td>
    <td>'.$buttonBack.'</td>
  </tr>
  </table>
');

Example: Use with Placeholders

$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 &rarr;</td>
    <td>%btnNext%</td>
  </tr>
  <tr>
    <td>To go back to the previous page,
        press this button &rarr;</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.

en/create/functions/buttoncode.txt · Last modified: 04.01.2015 14:29 by alexander.ritter
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki