- Posts: 9
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Delete select options (dropdown list) via java script
- jonaskoeppel
- Topic Author
- Offline
- New Member
Less
More
10 years 4 months ago - 10 years 4 months ago #102715
by jonaskoeppel
Delete select options (dropdown list) via java script was created by jonaskoeppel
Hi everyone,
I've got a quick question which is probably not a big deal but is breaking my nerve.
I'm trying to implement two cascading dropdown lists (the answer options of the second depend on the answer of the first ...). I found several threads in the forum regarding this question but the simplest solution seemed the one in the LS manual:
manual.limesurvey.org/Workarounds:_Manip..._Javascript#Method_2
So far so good. The only problem: it doesn't work. The java script runs properly (tested with alert()) but it won't remove the answer options. Anyone has an idea why this doesn't work?
I also tried the following to test it but it didn't work eighter.
$('#answer' + '{ID.sgqa}').click(function(){
$("#jquery-select option[value='test_value']").remove();
});
Some help would be much appreciated, thanks a lot in advance! Thanks in general for the great work of the developpers!
Jonas
I've got a quick question which is probably not a big deal but is breaking my nerve.
I'm trying to implement two cascading dropdown lists (the answer options of the second depend on the answer of the first ...). I found several threads in the forum regarding this question but the simplest solution seemed the one in the LS manual:
manual.limesurvey.org/Workarounds:_Manip..._Javascript#Method_2
So far so good. The only problem: it doesn't work. The java script runs properly (tested with alert()) but it won't remove the answer options. Anyone has an idea why this doesn't work?
I also tried the following to test it but it didn't work eighter.
$('#answer' + '{ID.sgqa}').click(function(){
$("#jquery-select option[value='test_value']").remove();
});
Some help would be much appreciated, thanks a lot in advance! Thanks in general for the great work of the developpers!
Jonas
Last edit: 10 years 4 months ago by jonaskoeppel.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
10 years 4 months ago - 8 years 1 month ago #102718
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Delete select options (dropdown list) via java script
Hi Jonas,
I do a complet javascript file for 1.92:
demonstration.sondages.pro/upload/templa...nade/selectfilter.js
I didn't test on 2.0, but can do the trick, think it work too.
The 2 question need to be in same group
demonstration.sondages.pro/82885/lang-fr
PS: script work without update in 2.00
limesurvey.sondages.pro/survey/index/sid...85/newtest/Y/lang/fr
For 2.5:
I do a complet javascript file for 1.92:
demonstration.sondages.pro/upload/templa...nade/selectfilter.js
I didn't test on 2.0, but can do the trick, think it work too.
The 2 question need to be in same group
demonstration.sondages.pro/82885/lang-fr
PS: script work without update in 2.00
limesurvey.sondages.pro/survey/index/sid...85/newtest/Y/lang/fr
Code:
<script type="text/javascript" src="http://demonstration.sondages.pro/upload/templates/select_filter_citronade/selectfilter.js"></script> <script type="text/javascript" charset="utf-8"> selectFilterByCode({QID},{SECTION.qid}); </script>
For 2.5:
deejroamer wrote: @DenisChenu, Thank you for your amazing out of the box script. I just modded it a bit so that the CSS of the new select is same as it was for the original select.
Link Here
I am not sure how long link will be up so To do the same
Add this lineCode:var classSelectFilter = $("#question"+qID).find("select").attr('class');
Mod this lineCode:var NewSelectElement = "<select id='"+idNewSelectFilter+"' class='"+classSelectFilter+"'><option value=''>"+$("#"+idSelectFilter+" option[value='']:first").text()+"</option></select>";
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 8 years 1 month ago by DenisChenu. Reason: Add 2.50
The following user(s) said Thank You: rquirola
The topic has been locked.
- jonaskoeppel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 4 months ago #102722
by jonaskoeppel
Replied by jonaskoeppel on topic Delete select options (dropdown list) via java script
Well, well, that's all I could ever hope for, or even more.. And that in no time. Thank you very much!
Great work, keep going like this!
Jonas
PS: Denis, j'ai constaté que tes réponses sont plus rapides au forum que par mail, peut-être c'est par ce moyen que je t'écrivrai au prochainement
Great work, keep going like this!
Jonas
PS: Denis, j'ai constaté que tes réponses sont plus rapides au forum que par mail, peut-être c'est par ce moyen que je t'écrivrai au prochainement
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
10 years 4 months ago #102724
by DenisChenu
Je prend pas plus de 3 minutes par poste sur le forum ... et encore ...
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Delete select options (dropdown list) via java script
Non,jonaskoeppel wrote: PS: Denis, j'ai constaté que tes réponses sont plus rapides au forum que par mail, peut-être c'est par ce moyen que je t'écrivrai au prochainement
Je prend pas plus de 3 minutes par poste sur le forum ... et encore ...
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- jonaskoeppel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 4 months ago #102739
by jonaskoeppel
Replied by jonaskoeppel on topic Delete select options (dropdown list) via java script
I tested the script, works like a charm (why shouldn't it ..).
Now I have one last question: can I extend it in an easy way to a higher (for instance third) level? Meaning instead of just comparing the first character, I want to compare the first and the second:
First level: A, B, ...
Second level: A1, A2, B1, B2, ...
Third level: A1a, A1b, A2a, A2b, B1a, B1b, B2a, B2b, ...
Thanks already for your help.
Jonas
Now I have one last question: can I extend it in an easy way to a higher (for instance third) level? Meaning instead of just comparing the first character, I want to compare the first and the second:
First level: A, B, ...
Second level: A1, A2, B1, B2, ...
Third level: A1a, A1b, A2a, A2b, B1a, B1b, B2a, B2b, ...
Thanks already for your help.
Jonas
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
10 years 4 months ago #102749
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Delete select options (dropdown list) via java script
Hi,
Think you can without updating the script.
But you have to use 2 times the function.
If it was Q1,Q2,Q3:
In Q2:
selectFilterByCode({QID},{Q1.qid});
and in Q3
selectFilterByCode({QID},{Q2.qid});
There are a fix for "select empry in first Question to do:
You have to add a line after line 44:
If there are condition on this question.
Denis
Think you can without updating the script.
But you have to use 2 times the function.
If it was Q1,Q2,Q3:
In Q2:
selectFilterByCode({QID},{Q1.qid});
and in Q3
selectFilterByCode({QID},{Q2.qid});
There are a fix for "select empry in first Question to do:
You have to add a line after line 44:
Code:
$('#'+idSelectFilter).trigger('change');
Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- jonaskoeppel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 4 months ago #102890
by jonaskoeppel
Replied by jonaskoeppel on topic Delete select options (dropdown list) via java script
Perfect! Thanks a lot Denis!
A quick suggestion: maybe you could replace the work around in the manual ( manual.limesurvey.org/Workarounds:_Manip..._Javascript#Method_2 ) with your method, since yours is a lot more sophisticated and works out of the box. That way others won't have to search the forums..
Wish you nice holidays!
Jonas
A quick suggestion: maybe you could replace the work around in the manual ( manual.limesurvey.org/Workarounds:_Manip..._Javascript#Method_2 ) with your method, since yours is a lot more sophisticated and works out of the box. That way others won't have to search the forums..
Wish you nice holidays!
Jonas
The topic has been locked.
- ongkichilam
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 0
9 years 7 months ago - 9 years 7 months ago #112372
by ongkichilam
Replied by ongkichilam on topic Delete select options (dropdown list) via java script
Help!
I wanted to implement this I don't understand how Denis managed to include the script just for a specific question.
His solution is so neat but does it appear only under div id = question18699 ?
I wanted to implement this I don't understand how Denis managed to include the script just for a specific question.
His solution is so neat but does it appear only under div id = question18699 ?
Last edit: 9 years 7 months ago by ongkichilam. Reason: typo
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
9 years 7 months ago #112374
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Delete select options (dropdown list) via java script
Hi,
You have to put the script in question text source (or help).
manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3F
{QID} is replaced by actual question id, then no need to update.
{Q1.qid} is replacxed by the id of Q1 question code.
Denis
You have to put the script in question text source (or help).
manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3F
{QID} is replaced by actual question id, then no need to update.
{Q1.qid} is replacxed by the id of Q1 question code.
Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- ongkichilam
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 0
9 years 7 months ago #112375
by ongkichilam
Replied by ongkichilam on topic Delete select options (dropdown list) via java script
Like this?
{if(QID=='894', "<script type='text/javascript' src='{TEMPLATEURL}selectfilter.js'></script><script type='text/javascript' charset='utf-8'>selectFilterByCode(894,895);</script>", "")}
{if(QID=='894', "<script type='text/javascript' src='{TEMPLATEURL}selectfilter.js'></script><script type='text/javascript' charset='utf-8'>selectFilterByCode(894,895);</script>", "")}
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
9 years 7 months ago #112376
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Delete select options (dropdown list) via java script
Why put if ?
You put this in question 894 source, not elsewhere.
You put this in question 894 source, not elsewhere.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- ongkichilam
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 0
9 years 7 months ago #112378
by ongkichilam
Replied by ongkichilam on topic Delete select options (dropdown list) via java script
Looks like I am missing something.... where exactly is the 'question source'?
I did that at templates/question.pstpl
I did that at templates/question.pstpl
The topic has been locked.