Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
en:create:inputs-single [25.06.2013 17:24] – created janisaltherren:create:inputs-single [11.12.2017 21:39] – Added JavaScript info admin
Line 5: Line 5:
 **Important:** The question types "selection" and "multiple choice" provide this function by simply checking a box. See [[selection-textinput|Free text inputs within a selection]] how to do this. **Important:** The question types "selection" and "multiple choice" provide this function by simply checking a box. See [[selection-textinput|Free text inputs within a selection]] how to do this.
  
-How to achieve a similar output with scales and other question types and how to provide a dropdown selection inside another question is described here. SoSciSurvey provides the PHP-function ''[[functions-output#prepare_input|prepare_input()]]'' to achieve this. We will guide you through using this function using the following example.+How to achieve a similar output with scales and other question types and how to provide a dropdown selection inside another question is described here. SoSciSurvey provides the PHP-function ''[[:en:create:functions:prepare_input|prepare_input()]]'' to achieve this. We will guide you through using this function using the following example.
  
 {{:en:create:scr.inputs-single.complete.png?nolink|Example for freely placed input fields}} {{:en:create:scr.inputs-single.complete.png?nolink|Example for freely placed input fields}}
Line 49: Line 49:
 The other input field is a dropdown selection. We don't just need one item but the whole question "ZE03". So you simply don't mention the item ID inside the placeholder: You use "%ZE03%". The other input field is a dropdown selection. We don't just need one item but the whole question "ZE03". So you simply don't mention the item ID inside the placeholder: You use "%ZE03%".
  
-As the preview still won't show much, you need to use php when assembling the questionnaire. When creating the questionnaire, add the element //PHP-code// ([[php|short guide to php]]). In this php-code, the input fields are prepared with [[functions-output#prepare_input|prepare_input()]] first, afterwards (!) you call the superior question ZE01 with its placeholder-items.+As the preview still won't show much, you need to use php when assembling the questionnaire. When creating the questionnaire, add the element //PHP-code// ([[php|short guide to php]]). In this php-code, the input fields are prepared with [[:en:create:functions:prepare_input|prepare_input()]] first, afterwards (!) you call the superior question ZE01 with its placeholder-items.
  
 <code php> <code php>
Line 62: Line 62:
  
 {{:en:create:scr.inputs-single.complete2.png?nolink|Example for freely placed input fields}} {{:en:create:scr.inputs-single.complete2.png?nolink|Example for freely placed input fields}}
 +
 +
 +====== Optimization =======
 +
 +An open-ended [[selection-textinput|text input in a normal selection question]] automatically selects the appropriate option when the respondent writes something into the text field. When text inputs are placed using `prepare_input()`, they are not automatically associated with the corresponding option. This can be set up using [[: de: create: javascript|JavaScript]].
 +
 +
 +===== Extended Selection and Text ====
 +
 +For example, if a question of the type "Extended Selection" (single or multiple choice) is used, insert the following JavaScript code (e. g. in an HTML code element) under the question.
 +
 +<code javascript>
 +<script type="text/javascript">
 +QuestionSelect.LinkSelect2Text("AU01_12", "TE01_01");
 +</script>
 +</code>
 +
 +The first parameter in the function `QuestionSelect.LinkSelect2Text()` specifies the HTML ID of the radio button or checkbox, in the example the option with the code 12 in question AU01 (an extended selection that allows multiple choice selection). The second parameter is the HTML identifier of the corresponding text input (here the first input in question TE01).
 +
 +The function `prepare_input ()` (in the PHP code at the top of the page) would have been used in this example for the identifier ''TE01_01''.
 +
 +If more than one open-ended inputs are used, you can simply call the function several times:
 +
 +<code javascript>
 +<script type="text/javascript">
 +QuestionSelect.LinkSelect2Text("AU01_12", "TE01_01");
 +QuestionSelect.LinkSelect2Text("AU01_16", "TE01_02");
 +QuestionSelect.LinkSelect2Text("AU01_221", "TE01_03");
 +</script>
 +</code>
en/create/inputs-single.txt · Last modified: 17.03.2021 20:52 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki