- Posts: 14
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
"Multiple options" question with several primary and secundary options
- marba
- Topic Author
- Offline
- New Member
Less
More
8 years 10 months ago #120575
by marba
Replied by marba on topic "Multiple options" question with several primary and secundary options
Of course, I had to be missing something :laugh:
I can also try to put some conditions to hide the other options if certain answers are selected, instead of the exclusive options... Or would that create the same problem?
@Bigred, so you had some options always hidden, and then they would appear in some situations? I need the opposite, to hide if some are selected.
I can also try to put some conditions to hide the other options if certain answers are selected, instead of the exclusive options... Or would that create the same problem?
@Bigred, so you had some options always hidden, and then they would appear in some situations? I need the opposite, to hide if some are selected.
The topic has been locked.
- Bigred01
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 33
8 years 10 months ago #120576
by Bigred01
Replied by Bigred01 on topic "Multiple options" question with several primary and secundary options
This would expand only the secondary list under the primary you click like it would do without the exclusive options. I'm pretty sure the exclusive script is changing the display property of the list items and overwriting the .hide(). Adding the class with the property display:none!important ensures that it will be hidden until you want to show it.
In the function, change the .hide() to .addClass('display-none') and .show() to .removeClass('display-none') then at the bottom of your template.css file add .display-none { display:none!important; }.
Now if you want them all to show initially then hide the secondary options of unselected primaries when a selection is made, this function wont work for that.
In the function, change the .hide() to .addClass('display-none') and .show() to .removeClass('display-none') then at the bottom of your template.css file add .display-none { display:none!important; }.
Now if you want them all to show initially then hide the secondary options of unselected primaries when a selection is made, this function wont work for that.
The following user(s) said Thank You: marba
The topic has been locked.
- marba
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
8 years 10 months ago #120613
by marba
Replied by marba on topic "Multiple options" question with several primary and secundary options
Thank you Bigred, that was helpful!
I did those changes in the script and css, and now there is no problem with the opening secondary options
Just had to write in css without the /!important/ part, though. A warning sign appeared in the css file about it, and the solution in fact only worked after I removed it.
I think the best part from Limesurvey is this forum. I'm learning loads with you people. thanks
Just in case someone else needs this solution, I write here how it looks like now:
Template.js
Template.css:
I did those changes in the script and css, and now there is no problem with the opening secondary options
Just had to write in css without the /!important/ part, though. A warning sign appeared in the css file about it, and the solution in fact only worked after I removed it.
I think the best part from Limesurvey is this forum. I'm learning loads with you people. thanks
Just in case someone else needs this solution, I write here how it looks like now:
Template.js
Code:
// A function to handle "secondary" checkboxes function secondaryCheckboxes(qID, primaryPosition, secondaryCount) { // Identify the elements var thisQuestion = $('#question'+qID); var primaryRow = $('li.question-item:eq('+(primaryPosition-1)+')', thisQuestion); var primaryInput = $('input.checkbox', primaryRow); var secondaryRows = primaryRow.nextAll('li.question-item:lt('+(secondaryCount)+')'); var secondaryInputs = $('input.checkbox', secondaryRows); // Indent the secondaries secondaryRows.css({ 'margin-left':'2.5em' }); // Initial states of the secondary answers if (primaryInput.prop('checked') == false ) { secondaryRows.addClass('display-none') } // A listener on the primary answer to show or hide secondary answers primaryInput.click(function (event) { // Hide/show the secondary answers accordingly if (!$(this).is(':checked')) { secondaryRows.addClass('display-none') secondaryInputs.prop('checked', false); secondaryInputs.each(function(i) { checkconditions(this.value, this.name, this.type); }); } else { secondaryRows.removeClass('display-none') } }); }
Template.css:
Code:
.display-none { display:none; }
The topic has been locked.