Hi all,
That's done
So if someone is looking at creating the same array (array with multiple scale, using drop downs), here are the steps to follow :
1) Create a Text Array with multiple columns.
2) Edite the question. Go in the question frame (under the question code), then click on "SOURCE"
3) Add this code :
<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>
5) Change the red text with
- Right number of the question
- SQ00X ["Dropdown answer proposition1", Dropdown answer proposition2", Dropdown answer proposition3" ...and so on]
6) Then save the question and do a little victory dance :laugh:
Thanks to everyone helping
Cheers and have a good day
Julien