Array question with answers in dropdown boxes

Plus d'informations
il y a 6 ans 8 mois #58190 par Usapuka
Usapuka a créé le sujet : Array question with answers in dropdown boxes
Hi,How can I do an array question with text answers in a dropdown box?
Thank you,

Connexion pour participer à la conversation.

Plus d'informations
il y a 6 ans 8 mois #58217 par tpartner
tpartner a répondu au sujet : Array question with answers in dropdown boxes

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Les utilisateur(s) suivant ont remercié: Usapuka

Connexion pour participer à la conversation.

Plus d'informations
il y a 6 ans 8 mois #58235 par Usapuka
Usapuka a répondu au sujet : Array question with answers in dropdown boxes
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!

Connexion pour participer à la conversation.

Plus d'informations
il y a 6 ans 8 mois #58244 par tpartner
tpartner a répondu au sujet : Array question with answers in dropdown boxes
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.
Les utilisateur(s) suivant ont remercié: Usapuka

Connexion pour participer à la conversation.

Plus d'informations
il y a 6 ans 8 mois #58286 par Usapuka
Usapuka a répondu au sujet : Array question with answers in dropdown boxes
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

Fichier attaché :

Nom du fichier : limesurvey..._298.lsq
Taille du ficher :8 ko
Pièces jointes :

Connexion pour participer à la conversation.

Plus d'informations
il y a 6 ans 8 mois #58296 par tpartner
tpartner a répondu au sujet : Array question with answers in dropdown boxes
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.

Connexion pour participer à la conversation.

Plus d'informations
il y a 6 ans 8 mois #58319 par Usapuka
Usapuka a répondu au sujet : Array question with answers in dropdown boxes
Hi Tony,

Thank you very much. Now is working :cheer:

Best regards from Buenos Aires!

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94880 par ricardo01
ricardo01 a répondu au sujet : Array question with answers in dropdown boxes
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...



But I only want 6 options in column 3.

Thanks you

ricardo
Pièces jointes :

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94885 par ricardo01
ricardo01 a répondu au sujet : Array question with answers in dropdown boxes
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.

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94888 par Mazi
Mazi a répondu au sujet : Array question with answers in dropdown boxes
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)survey-consulting.com'"

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois - il y a 4 ans 7 mois #94907 par ricardo01
ricardo01 a répondu au sujet : Array question with answers in dropdown boxes

Fichier attaché :

Nom du fichier : dropdown.txt
Taille du ficher :27 ko

Thank you Mazi,

attached find the java script and the question in .lsq format. Again, in columns 2 and 3 I have fewer items than in column 1, so I'd like to get rid of those extra numbers.




Thanks for your help


Fichier attaché :

Nom du fichier : dropdownquestion.lsq
Taille du ficher :34 ko


Fichier attaché :

Nom du fichier : dropdown.txt
Taille du ficher :27 ko
Pièces jointes :
Dernière édition: il y a 4 ans 7 mois par ricardo01. Raison: attach file

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94926 par ricardo01
ricardo01 a répondu au sujet : Array question with answers in dropdown boxes
I think I almost got it. I hid the text for the items I don't need. However, when I paste and save the javascript in the question source, the code breaks around line 847. Is there a limited amount of text that can be saved in the question source?

This is what I paste




and this is what is saved




This is my updated javascript

Fichier attaché :

Nom du fichier : dropdown_2...4-15.txt
Taille du ficher :69 ko





Thanks in advance for your help
Pièces jointes :

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94931 par tpartner
tpartner a répondu au sujet : Array question with answers in dropdown boxes
Dunno why that's being truncated but you should be able to replace all of those lines with a simple loop.

Replace all of the lines like this:
$('#question174 .answer_cell_003 option[value=6]').text('').hide();


With this block:
$('#question174 .answer_cell_003 option').each(function(i){
	if($(this).val() > 5) {
		$(this).remove();
	}
});

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

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94937 par ricardo01
ricardo01 a répondu au sujet : Array question with answers in dropdown boxes
Thanks Tony! It worked for this example.

I need to create a similar question listing US universities (n=3492)...my javascript has 3983 lines. The problem is that when I paste it in the question source, it gets truncated around line 695.

is there a way to solve this?

ricardo

Connexion pour participer à la conversation.

Plus d'informations
il y a 4 ans 7 mois #94940 par tpartner
tpartner a répondu au sujet : Array question with answers in dropdown boxes
Try removing the script from the question source and place it at the end of template.js

Remove the opening script tag:
<script charset="utf-8" type="text/javascript">
And the closing script tag:
</script>

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

Connexion pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!