- Posts: 44
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to set conditions for dropdown in a multiple short text ?
- SherriChen
- Topic Author
- Offline
- Senior Member
Less
More
4 years 10 months ago #185718
by SherriChen
How to set conditions for dropdown in a multiple short text ? was created by SherriChen
Hello,
I have a multiple short text question and I changed one of the subquestions into the dropdown format.
For example:
SQ001: Text
SQ002: Text
SQ003: dropdown (Select 1, select 2, select 3)
SQ004: Text
I want to make SQ004 only show when respondents choose "select 3" in SQ003.
I tried to set conditions for SQ004, it works. But it has a problem. When I choose "select 3", it does not show SQ004 automatically, but when I click "next", it alerts me that SQ004 is not answered. At that time, SQ004 shows.
Can I make SQ004 show automatically after I choose "select 3" in SQ003?
Thank you for your help.
I have a multiple short text question and I changed one of the subquestions into the dropdown format.
For example:
SQ001: Text
SQ002: Text
SQ003: dropdown (Select 1, select 2, select 3)
SQ004: Text
I want to make SQ004 only show when respondents choose "select 3" in SQ003.
I tried to set conditions for SQ004, it works. But it has a problem. When I choose "select 3", it does not show SQ004 automatically, but when I click "next", it alerts me that SQ004 is not answered. At that time, SQ004 shows.
Can I make SQ004 show automatically after I choose "select 3" in SQ003?
Thank you for your help.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 10 months ago #185720
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 How to set conditions for dropdown in a multiple short text ?
Can you show a screen shot of survey logic file ?
Or send a lss
And inform us of your LimeSurvey version …
Or send a lss
And inform us of your LimeSurvey version …
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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 10 months ago - 4 years 10 months ago #185729
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 How to set conditions for dropdown in a multiple short text ?
How did you change one of the subquestions into the dropdown format? With JavaScript? If so, can you attach that script or, even better as Denis suggests, attach a small sample survey (.lss file) containing only the relevant question.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 10 months ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- SherriChen
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
4 years 10 months ago #185732
by SherriChen
Replied by SherriChen on topic How to set conditions for dropdown in a multiple short text ?
Here is the sample survey. I want to make SQ005 show only when people choose "Other education level" in SQ004. I use LS 3.17.5. Thank you for your help.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 10 months ago #185733
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to set conditions for dropdown in a multiple short text ?
Hi,
try to test for the text "Other education level" instaed of code "15"
Joffm
try to test for the text "Other education level" instaed of code "15"
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- SherriChen
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
4 years 10 months ago #185736
by SherriChen
Replied by SherriChen on topic How to set conditions for dropdown in a multiple short text ?
Hi Joffm,
Thank you for your reply. I have tried, but it doesn't work.
Thank you for your reply. I have tried, but it doesn't work.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 10 months ago #185737
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to set conditions for dropdown in a multiple short text ?
Hi,
It was a guess, because your survey doesn't show the drop-down here (Version 3.17.4+190529)
And in another survey with javascript drop-downs it was like this; that you had to use the labels.
Sorry
Joffm
It was a guess, because your survey doesn't show the drop-down here (Version 3.17.4+190529)
And in another survey with javascript drop-downs it was like this; that you had to use the labels.
Sorry
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 10 months ago #185738
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 How to set conditions for dropdown in a multiple short text ?
The problem is that Expression Manager is not being fired by the "change" or "keyup" events (I don't know why).
Use this script to insert the drop-down:
Working survey attached:
Use this script to insert the drop-down:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { var qID = {QID}; var inputNum = 4; // Define the select element (dropdown) var prov1 = '<select id="prov1" class="form-control">\ <option value="">--Choose education level--</option>\ <option value="1">Primary education</option>\ <option value="2">Pre-vocational secondary education (VMBO)</option>\ <option value="3">Senior general secondary education (HAVO) substructure (Year 1-3)</option>\ <option value="4">Senior general secondary education (HAVO) (Year 4-5)</option>\ <option value="5">Senior general secondary education (HAVO) (Year 1-5)</option>\ <option value="6">Pre-university education (VWO) substructure (Year 1-3)</option>\ <option value="7">Pre-university education (VWO) (Year 4-6) </option>\ <option value="7">Pre-university education (VWO) (Year 1-6) </option>\ <option value="8">MBO Level 1</option>\ <option value="9">MBO level 2-4</option>\ <option value="10">Higher professional education (HBO) bachelor</option>\ <option value="11">Higher professional education (HBO) master</option>\ <option value="12">University education (WO) bachelor</option>\ <option value="13">University education (WO) master</option>\ <option value="14">University education (WO) doctor</option>\ <option value="15">Other education level</option>\ </select>'; // Hide the text input $('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').hide(); // Insert the select elements if($('#question'+qID+' .question-item:eq('+(inputNum-1)+') select').length == 0) { $('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').before(prov1); } // Initially select an option if the question has already been answered $('#question'+qID+' select').each(function(i) { if($.trim($(this).next('input[type="text"]').val()) != '') { $(this).val($.trim($(this).next('input[type="text"]').val())); } }); // Listener on the dropdowns - insert selected values into hidden text input $('#question'+qID+' select').change(function() { var thisInput = $(this).next('input[type="text"]'); $(thisInput).val($(this).val()); checkconditions($(thisInput).attr('value'), $(thisInput).attr('name'), 'text'); }); // Some styles $('#question'+qID+' select').css({ 'margin':'0.3em 0 0 0' }); }); </script>
Working survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- SherriChen
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
4 years 10 months ago #185739
by SherriChen
Replied by SherriChen on topic How to set conditions for dropdown in a multiple short text ?
Hi,
I try to delete the first subquestion(SQ001 with the date button), it works. So I guess, maybe there is something wrong with my script. I don' t know much about Javascript. Can you help to check it? Thank you.
I try to delete the first subquestion(SQ001 with the date button), it works. So I guess, maybe there is something wrong with my script. I don' t know much about Javascript. Can you help to check it? Thank you.
The topic has been locked.
- SherriChen
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
4 years 10 months ago #185742
by SherriChen
Replied by SherriChen on topic How to set conditions for dropdown in a multiple short text ?
WOW! Perfect! It works well. Thank you very much for your help!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 10 months ago #185743
by DenisChenu
See github.com/LimeSurvey/LimeSurvey/blob/e2...em_javascript.js#L38
Alternate solution
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 How to set conditions for dropdown in a multiple short text ?
Because event is attached to .select-item select or .dropdown-item selecttpartner wrote: The problem is that Expression Manager is not being fired by the "change" or "keyup" events (I don't know why).
See github.com/LimeSurvey/LimeSurvey/blob/e2...em_javascript.js#L38
Alternate solution
Code:
$('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').hide().closest(".answer-item").addClass("dropdown-item");
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.
- SherriChen
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
4 years 10 months ago #185745
by SherriChen
Replied by SherriChen on topic How to set conditions for dropdown in a multiple short text ?
Thank you!
The topic has been locked.