Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:create:functions:buttoncode [04.01.2015 13:04] – [Tips] alexander.ritter | en:create:functions:buttoncode [25.08.2020 11:24] (current) – [Example: Use with Placeholders] sophia.schauer |
---|
* ''%%'next'%%'' -- Next button | * ''%%'next'%%'' -- Next button |
* ''%%'back'%%'' -- Back button | * ''%%'back'%%'' -- Back button |
| * ''%%'break'%%'' -- Button to interrupt the interview |
| * ''%%'leave'%%'' -- Button to cancel and delete data |
| |
| |
**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:** 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, the automatic insertion of the buttons at the end of the current page is prevented. | **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 ===== |
| |
| <code php> |
| html( |
| '<div style="margin: 4em; text-align: center">'. |
| buttonCode('next'). |
| '</div>' |
| ); |
| </code> |
| |
**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 guidance for [[:en:create:layout|Questionnaire Layouts]]. | |
| |
===== Example: Insert Directly in HTML Code ===== | ===== Example: Insert Directly in HTML Code ===== |
$buttonBack = buttonCode('back'); // buttons in 2 variables | $buttonBack = buttonCode('back'); // buttons in 2 variables |
| |
// Insert the HTML codes into the questionnaire, e.g. in a table | // Insertion of the HTML codes into the questionnaire, e.g. in a table |
html(' | html(' |
<table cellspacing="10" cellpadding="0"> | <table cellspacing="10" cellpadding="0"> |
</colgroup> | </colgroup> |
<tr> | <tr> |
<td>Press this button, | <td>Press this button |
to go to the next page →</td> | to go to the next page →</td> |
<td>'.$buttonNext.'</td> | <td>'.$buttonNext.'</td> |
$buttonNext = buttonCode('next'); // Saves the HTML code for the | $buttonNext = buttonCode('next'); // Saves the HTML code for the |
$buttonBack = buttonCode('back'); // buttons in two variables | $buttonBack = buttonCode('back'); // buttons in two variables |
replace('%btnNext%', $buttonNext); // Store for placeholders | replace('%btnNext%', $buttonNext, 'html'); // Store for placeholders |
replace('%btnBack%', $buttonBack); | replace('%btnBack%', $buttonBack, 'html'); |
text('buttons'); // display text in the questionnaire | text('buttons'); // display text in the questionnaire |
</code> | </code> |