- Posts: 46
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
three dependent drop downs in an array text using java script
- jerryd
- Topic Author
- Offline
- Senior Member
Less
More
8 years 1 month ago - 8 years 1 month ago #131135
by jerryd
Thanks alot
jerryd
three dependent drop downs in an array text using java script was created by jerryd
hello every one i am really need to have three dependent drop downs in array text i was trying to work on a condition but the database became very boring and hug so is their any option using only three table and filter it based one the needed answer .
Region Amhara
Zone (must filter only)Awi
Woreda(must filter only Banja)
water shade( Fetam)
Micro water shade(Korara)
i have large drop down and many branch drop downs for each of them so please i am working this for one organization i have to finish until Sunday.also i can't get any answer about( variable length array don't work on printing)
Thank You.
Thank you
Region Amhara
Zone (must filter only)Awi
Woreda(must filter only Banja)
water shade( Fetam)
Micro water shade(Korara)
i have large drop down and many branch drop downs for each of them so please i am working this for one organization i have to finish until Sunday.also i can't get any answer about( variable length array don't work on printing)
Thank You.
Thank you
Thanks alot
jerryd
Attachments:
Last edit: 8 years 1 month ago by jerryd. Reason: missing to attachement
The topic has been locked.
- kadejo
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 2
8 years 1 month ago - 8 years 1 month ago #131226
by kadejo
Replied by kadejo on topic three dependent drop downs in an array text using java script
Hi!
Well... for sure may be a better/elegant way to solve it , but we just managed to cascade two drop downs this way, the third can be achieved taking into account both previous selections.
You should put this code in the text of the second (& third) drop down, source mode of course, and customize properly (question numbers and limits).
Hope it works for your needs!
Best regards from El Salvador
Well... for sure may be a better/elegant way to solve it , but we just managed to cascade two drop downs this way, the third can be achieved taking into account both previous selections.
You should put this code in the text of the second (& third) drop down, source mode of course, and customize properly (question numbers and limits).
Hope it works for your needs!
Best regards from El Salvador
Code:
//By: corozco@salud.gob.sv / cmartin@salud.gob.sv //License: GNU/GPL v3 or later <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Initialy hiding all options of filtered question $('#question30 option').hide(); // Just show the first option: "choose..." $('#question30 option:eq(0)').show(); // The trigger $('#question29').on('change',function() { var value = $(this).find(':selected').val(); var start = 0; var end = 0; // Definition of limits switch (parseInt(value)) { case 1: start = 1; end = 12; break; case 2: start = 13; end = 21; break; case 3: start = 22; end = 54; break; case 4: start = 55; end = 70; break; case 5: start = 71; end = 92; break; case 6: start = 93; end = 114; break; case 7: start = 115; end = 132; break; case 8: start = 133; end = 158; break; case 9: start = 159; end = 178; break; case 10: start = 179; end = 198; break; case 11: start = 199; end = 210; break; case 12: start = 211; end = 223; break; case 13: start = 224; end = 239; break; case 14: start = 240; end = 262; break; default: start = 0; end = 0; break; } //alert(value+' '+start+' '+end); //loop for hiding from the first drop-down item until the first showed for(i=1; i < start; i++) { $('#question30 option:eq('+i+')').hide(); } //loop for showing related items for(i=start; i <= end; i++) { $('#question30 option:eq('+i+')').show(); } //loop for hiding from the last showed til the last option for(i=end+1; i <= 263; i++) { $('#question30 option:eq('+i+')').hide(); } }); }); </script>
Last edit: 8 years 1 month ago by kadejo. Reason: typo in the code :p
The following user(s) said Thank You: jerryd
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
8 years 1 month ago #131235
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 three dependent drop downs in an array text using java script
Hi kadejo :
Maybe replace #question30 by #question(QID} or by #question(QQ.qid}
Maybe replace #question30 by #question(QID} or by #question(QQ.qid}
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.
- jerryd
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
- Thank you received: 0
8 years 1 month ago #131329
by jerryd
Thanks alot
jerryd
Replied by jerryd on topic three dependent drop downs in an array text using java script
Tnx a lot for the replay but i am not smart with programming thing i was trying to put the code and change the question number to answer-code on the source of the questions but it doesn't work could you pls attach for me the .lss file as an example
jerryd
jerryd
Thanks alot
jerryd
The topic has been locked.
- kadejo
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 2
8 years 1 month ago #131353
by kadejo
Replied by kadejo on topic three dependent drop downs in an array text using java script
Sure!
By the way, I can tell you that will have to link another drop down question, then having the three dependent drop downs you asked, but that will happen next week and knowing you're in a hurry, I'm attaching current .lss example for two drop downs: when I have the three I will post it too.
Best wishes!
By the way, I can tell you that will have to link another drop down question, then having the three dependent drop downs you asked, but that will happen next week and knowing you're in a hurry, I'm attaching current .lss example for two drop downs: when I have the three I will post it too.
Best wishes!
Attachments:
The following user(s) said Thank You: jerryd
The topic has been locked.
- jerryd
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
- Thank you received: 0
8 years 1 month ago #131425
by jerryd
Thanks alot
jerryd
Replied by jerryd on topic three dependent drop downs in an array text using java script
Thanks a lot kadejo you save my life it really helpful and still need your help for three dependent drop downs and also if you have any idea about adding(+) button like variable length array but it doesn't work on printing so i cant add new lines using variable length array in my survey questions or if you have other solution instead of variable length array please like always if you have some example.....
Thanks,
Thanks,
Thanks alot
jerryd
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
8 years 1 month ago #131852
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 three dependent drop downs in an array text using java script
Hi,
For this purpose, i do a script : demonstration.sondages.pro/565163?newtest=Y#
3 dependant dropdown question : using code to filter : demonstration.sondages.pro/565163?newtest=Y#
Download the jsfile, and add the function in the question text:
For this purpose, i do a script : demonstration.sondages.pro/565163?newtest=Y#
3 dependant dropdown question : using code to filter : demonstration.sondages.pro/565163?newtest=Y#
Download the jsfile, and add the function in the question text:
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.
Attachments:
The topic has been locked.
- cstcandy
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
6 years 2 months ago #162949
by cstcandy
Replied by cstcandy on topic three dependent drop downs in an array text using java script
Hi kadejo,
I am using this script and it works.
However, it only works when viewing on desktop. It does not work on mobile and all codes are shown in the 2nd/3rd question. Can you please help?
Thanks very much!
I am using this script and it works.
However, it only works when viewing on desktop. It does not work on mobile and all codes are shown in the 2nd/3rd question. Can you please help?
Thanks very much!
The topic has been locked.
- cstcandy
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
6 years 2 months ago #162987
by cstcandy
Replied by cstcandy on topic three dependent drop downs in an array text using java script
I've found that the javascript actually works on Andriod device but not on iOS.
Anybody can help? [urgent ]
Anybody can help? [urgent ]
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 2 months ago #162998
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic three dependent drop downs in an array text using java script
Try implementing an alert to display JavaScript errors -
stackoverflow.com/questions/2604976/java...ors-in-a-popup-alert
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- cstcandy
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
6 years 2 months ago #163026
by cstcandy
Replied by cstcandy on topic three dependent drop downs in an array text using java script
Hi Tony Thanks for your reply!
Yet how do I solve the issue with this alert?
Yet how do I solve the issue with this alert?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 2 months ago #163070
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic three dependent drop downs in an array text using java script
That should let you know if a JavaScript error is preventing the script from running.
How to fix would depend on what the error is.
How to fix would depend on what the error is.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.