====== 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 ''[[: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: Insert Directly in HTML Code =====

<code php>
$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>
');
</code>


===== Example: Use with Placeholders =====

<code php>
$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
</code>

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**.

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

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.
