- Posts: 16
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
filter dropdowns in array
- barbacot
- Topic Author
- Offline
- New Member
Less
More
9 years 9 months ago - 9 years 9 months ago #110663
by barbacot
filter dropdowns in array was created by barbacot
I have an array (I can do it simple or with numbers) where on five rows I have five elements for the user to rate. I don't want to use the rating type question - it doesn't work well and for some users is confusing.
So, I choose dropdown presentation in the array and I populate the dropdowns with numbers from one to five.
Is it possible that when a user choose in one of the dropdowns a number this number will be deleted or mark disabled from the other dropdowns in the array?
So, I choose dropdown presentation in the array and I populate the dropdowns with numbers from one to five.
Is it possible that when a user choose in one of the dropdowns a number this number will be deleted or mark disabled from the other dropdowns in the array?
Last edit: 9 years 9 months ago by barbacot. Reason: syntax
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
9 years 9 months ago - 9 years 9 months ago #110664
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 filter dropdowns in array
Have a look at this post where an array type question is used for ranking -
www.limesurvey.org/en/forum/can-i-do-thi...king-question#106841
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 9 months ago by tpartner.
The topic has been locked.
- barbacot
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
9 years 9 months ago #110670
by barbacot
Thank you!
Just one more thing - I need to filter some rows in the array (all but the last) and I tried to use the solution provided HERE but it does not work in limesurvey 2.05
More specifically:
I need this because I hide some radio buttons on the last row and if the user click by mistake the hidden button it can be considered a valid answer and added to the number of array answer clicked.
Replied by barbacot on topic filter dropdowns in array
tpartner wrote: Have a look at this post where an array type question is used for ranking - www.limesurvey.org/en/forum/can-i-do-thi...king-question#106841 .
Thank you!
Just one more thing - I need to filter some rows in the array (all but the last) and I tried to use the solution provided HERE but it does not work in limesurvey 2.05
More specifically:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function () { // Call the mandatory row function with question ID mandatoryRows(QQ); // A function to render all but the last rows of an array mandatory function mandatoryRows(qID) { var warningText = 'Please complete the highlighted rows.'; // Add a mandatory class to all rows except the last one $('div#question'+qID+' table.question tbody[id^="javatbd"]:not(:last) tr').addClass('mandatory'); // Interrupt the submit function $('#movenextbtn, #movesubmitbtn').click(function(){ var fail = ''; // Loop through all mandatory rows and check for answers $('tr.mandatory').each(function(i){ if($('input.radio:checked', this).length < 1) { $('th, td', this).css({ 'background':'pink' }); fail = 1; } else { $('th, td', this).css({ 'background':'' }); } }); if(fail == 1) { alert (warningText); return false; } else { return true; } }); } }); </script>
I need this because I hide some radio buttons on the last row and if the user click by mistake the hidden button it can be considered a valid answer and added to the number of array answer clicked.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
9 years 9 months ago #110671
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 filter dropdowns in array
Try this:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function () { // Call the mandatory row function with question ID mandatoryRows(QQ); // A function to render all but the last rows of an array mandatory function mandatoryRows(qID) { var warningText = 'Please complete the highlighted rows.'; // Add a mandatory class to all rows except the last one $('div#question'+qID+' table.question tr[id^="javatbd"]:not(:last)').addClass('mandatory'); // Interrupt the submit function $('#movenextbtn, #movesubmitbtn').click(function(){ var fail = ''; // Loop through all mandatory rows and check for answers $('tr.mandatory').each(function(i){ if($('input.radio:checked', this).length < 1) { $('th, td', this).css({ 'background':'pink' }); fail = 1; } else { $('th, td', this).css({ 'background':'' }); } }); if(fail == 1) { alert (warningText); return false; } else { return true; } }); } }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: barbacot
The topic has been locked.
- barbacot
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
9 years 9 months ago - 9 years 9 months ago #110673
by barbacot
Flawless!!!
Thank you - so it was about the 'tr' element - changed design in 2.00+...
I noticed that there are some workarounds that are not working anymore in 2.05 like manual.limesurvey.org/Workarounds:_Manip...ble_Text.29_question because of this change in design - they require some detective work with google developer tools.
Replied by barbacot on topic filter dropdowns in array
tpartner wrote: Try this:
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function () { // Call the mandatory row function with question ID mandatoryRows(QQ); // A function to render all but the last rows of an array mandatory function mandatoryRows(qID) { var warningText = 'Please complete the highlighted rows.'; // Add a mandatory class to all rows except the last one $('div#question'+qID+' table.question tr[id^="javatbd"]:not(:last)').addClass('mandatory'); // Interrupt the submit function $('#movenextbtn, #movesubmitbtn').click(function(){ var fail = ''; // Loop through all mandatory rows and check for answers $('tr.mandatory').each(function(i){ if($('input.radio:checked', this).length < 1) { $('th, td', this).css({ 'background':'pink' }); fail = 1; } else { $('th, td', this).css({ 'background':'' }); } }); if(fail == 1) { alert (warningText); return false; } else { return true; } }); } }); </script>
Flawless!!!
Thank you - so it was about the 'tr' element - changed design in 2.00+...
I noticed that there are some workarounds that are not working anymore in 2.05 like manual.limesurvey.org/Workarounds:_Manip...ble_Text.29_question because of this change in design - they require some detective work with google developer tools.
Last edit: 9 years 9 months ago by barbacot.
The topic has been locked.