Welcome, Guest
Username: Password: Remember me

TOPIC: Array question with answers in dropdown boxes

Array question with answers in dropdown boxes 3 years 5 months ago #58190

  • Usapuka
  • Usapuka's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 45
  • Karma: 0
Hi,How can I do an array question with text answers in a dropdown box?
Thank you,
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 3 years 5 months ago #58217

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4120
  • Thank you received: 760
  • Karma: 346
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Usapuka

Re: Array question with answers in dropdown boxes 3 years 5 months ago #58235

  • Usapuka
  • Usapuka's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 45
  • Karma: 0
tpartner,

Thank you for your answer.
Sorry, I'm just beginning with LimeSurvey and I don't know much of javascript, so please excuse me, my first trial of the solution was a completed failure...
What I like to do is this (is in Spanish but can get the idea): http://tecnobiz.com.ar/Surveys/Oldelval/referentes
It is possible?

Thank you again!
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 3 years 5 months ago #58244

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4120
  • Thank you received: 760
  • Karma: 346
Ah, part of the problem is that you want different dropdowns in the same question.

To reproduce the first question in your example survey:

1) Set up your survey to use JavaScript.

2) Create an Array (Numbers) question with a minimum value of 1 and a maximum value of 5.

3)Add your x-scale and y-scale subquestions

4) Add the following script to the source of the array question. Replace "QQ" with the array question ID.

As stated in the referenced forum post, the replacement text in the dropdowns will not be stored in the data - you will need to map to it in post-survey analysis.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
        $('#questionQQ .answer_cell_001 option[value=1]').text('No recurro');
        $('#questionQQ .answer_cell_001 option[value=2]').text('Arocena Gustavo');
        $('#questionQQ .answer_cell_001 option[value=3]').text('Aspra Manuel');
        $('#questionQQ .answer_cell_001 option[value=4]').text('Bravo Ricardo');
        $('#questionQQ .answer_cell_001 option[value=5]').text('Zalazar Martin');
 
        $('#questionQQ .answer_cell_002 option[value=1]').text('No recurro');
        $('#questionQQ .answer_cell_002 option[value=2]').text('Bravo Ricardo');
        $('#questionQQ .answer_cell_002 option[value=3]').text('Fernandez Flavio');
        $('#questionQQ .answer_cell_002 option[value=4]').text('Zalazar Martin');
        $('#questionQQ .answer_cell_002 option[value=5]').text('').hide();
 
    });
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Usapuka

Re: Array question with answers in dropdown boxes 3 years 5 months ago #58286

  • Usapuka
  • Usapuka's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 45
  • Karma: 0
Tony,
Thank you for your explanation, I did what you told me but something is wrong... I still see the numbers instead of the text. Here I send you the question I did: please, can you take a look to it?
Thank you, Gabriel

File Attachment:

File Name: limesurvey_question_298.lsq
File Size: 8 KB
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 3 years 5 months ago #58296

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4120
  • Thank you received: 760
  • Karma: 346
It seems that the cell classes are different in Spanish (and presumably other languages).

Try this:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
        $('#question298 .answer_cell_00SQ001 option[value=1]').text('No recurro');
        $('#question298 .answer_cell_00SQ001 option[value=2]').text('Arocena Gustavo');
        $('#question298 .answer_cell_00SQ001 option[value=3]').text('Aspra Manuel');
        $('#question298 .answer_cell_00SQ001 option[value=4]').text('Bravo Ricardo');
        $('#question298 .answer_cell_00SQ001 option[value=5]').text('Zalazar Martin');
 
        $('#question298 .answer_cell_00SQ002 option[value=1]').text('No recurro');
        $('#question298 .answer_cell_00SQ002 option[value=2]').text('Bravo Ricardo');
        $('#question298 .answer_cell_00SQ002 option[value=3]').text('Fernandez Flavio');
        $('#question298 .answer_cell_00SQ002 option[value=4]').text('Zalazar Martin');
        $('#question298 .answer_cell_00SQ002 option[value=5]').text('').hide();
 
    });
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 3 years 5 months ago #58319

  • Usapuka
  • Usapuka's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 45
  • Karma: 0
Hi Tony,

Thank you very much. Now is working :cheer:

Best regards from Buenos Aires!
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 1 year 4 months ago #94880

  • ricardo
  • ricardo's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 110
  • Thank you received: 1
  • Karma: 0
Tony,

how can I create drop-drown lists with different number of items? for instance, 50 options for the first column, 10 for the second, and 5 for the third? This is what my test looks right now...

dropdownlist.png


But I only want 6 options in column 3.

Thanks you

ricardo
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 1 year 4 months ago #94885

  • ricardo
  • ricardo's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 110
  • Thank you received: 1
  • Karma: 0
Also, how can I use the apostrophe in the text in parentheses. When I use something like this (note King's college), the dropdown list doesn't show up.

$('#question174 .answer_cell_001 option[value=135]').text('King's College London');

But if I remove the apostrophe and just leave it as ('Kings College London'); it works fine.
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 1 year 4 months ago #94888

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 293
  • Karma: 248
1. Please post your Javascript and attach the question as LSQ file.

2. To escape the apostrophe, try ...King\'s College London...:
$('#question174 .answer_cell_001 option[value=135]').text('King\'s College London');

Alternatively, use quotes at the JavaScript so the apostrophe doesn't influence the quoting.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.141 seconds
Donation Image