- Posts: 10
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script> $(function(){ /** ID du questionnaire **/ var questionIdentifier = '#question17'; /** Options **/ var selectOptions = { 'SQ001': ["---", "OUI", "NON"], 'SQ002': ["---", "min. 1 fois par semaine", "min. 1 fois par mois", "min. 1 par an", "Jamais"], 'SQ003': ["---", "OUI", "NON", "Je ne sais pas"], 'SQ004': ["---", "0,25€", "0,50€", "0,75€", "1,00€", "1,25€", "1,50€", "1,75€", "2,0€", "2,5€", "3,0€", "3,5€", "4,0€", "4,5€", "5,0€", "5,5€", "6,0€", "6,5€", "7,0€", "7,5€", "8,0€", "8,5€", "9,0€", "9,5€", "10€" ] }; var createSelect = function(key) { var select = $('<select>'); $.each(selectOptions[key], function (id, value) { var option = $('<option value="' + value + '">' + value + '</option>'); select.append(option); }); return select; }; var getKey = function(name) { for (var testKey in selectOptions) { if (name.indexOf('_' + testKey) > -1) { return testKey; } } return null; }; $.each($(questionIdentifier).find('.subquestion-list input'), function(index, element){ var input = $(element); var name = input.attr('name'); if ('text' == input.attr('type')) { var key = getKey(name); if (null != key) { var select = createSelect(key); input.parent().append(select); select.val(input.val()); select.change(function(){ input.val(select.val()); }); input.css('display', 'none'); } } }); }); </script>
var questionIdentifier = '#question17'; /** Options **/ var selectOptions = { 'SQ001': ["---", "OUI", "NON"], 'SQ002': ["---", "min. 1 fois par semaine", "min. 1 fois par mois", "min. 1 par an", "Jamais"], 'SQ003': ["---", "OUI", "NON", "Je ne sais pas"], 'SQ004': ["---", "0,25€", "0,50€", "0,75€", "1,00€", "1,25€", "1,50€", "1,75€", "2,0€", "2,5€", "3,0€", "3,5€", "4,0€", "4,5€", "5,0€", "5,5€", "6,0€", "6,5€", "7,0€", "7,5€", "8,0€", "8,5€", "9,0€", "9,5€", "10€" ] };