- Posts: 5
- Thank you received: 0
- Community
- Forums
- English support forums
- Design issues
- How to add a condition to each sub-question of a double-scale table
How to add a condition to each sub-question of a double-scale table
I do not know how to create a table that would allow participants to click on the button "Was the opportunity available to you?" and on "Did you participate?", then add a condition that would allow people to indicate how many hours of training they received when they say they participated in the training. See image and example for more information. Thank you very much!
Marie-France
Please Log in or Create an account to join the conversation.
this is a nice paper-pencil questionnaire, but - as often -, you can draw a lot, but it is difficult to realize as an web based survey.
Well, in my opinion there are two solutions available at the moment here in the forum.
The first is based on the idea that it is not necessary to check "opportunity" and "participation" independently.
If somebody participated he had the opportunity. So we can check these two options as radio buttons.
The second let's you select both (just to show it)
Then you have to validate that "hours" is only entered if participated,
and in the second case that "participation" is only entered if "opportunity".
If you think this could suit your wishes, I'll send an LSS file of this (has to be improved a bit).
Joffm
One addition:
Improvement of first example:
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Please Log in or Create an account to join the conversation.
I think that the best solution for my survey is to use the second option (with the yes/or question) although I like the option with the buttons which is faster to respond.
So from what I understand, you will send me a code so that I can use the 2nd option you created?
Thanks again Joffm!!
Please Log in or Create an account to join the conversation.
The main thing is the javascript.
I called the X-axis codes "X001", "X002", ... Here you may adapt the wording.
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
var thisQuestion = $('#question{QID}');
// Insert selects
$('.answer-item.answer_cell_X001', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
<option value="">Yes/No...</option>\
<option value="1">Yes</option>\
<option value="2">No</option>\
</select>');
$('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
<option value="">Yes/No...</option>\
<option value="1">Yes</option>\
<option value="2">No</option>\
</select>');
// Listeners
$('.inserted-select', thisQuestion).on('change', function(i) {
if($(this).val() != '') {
$(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).trigger('change');
}
else {
$(this).closest('.answer-item').find('input:text').val('').trigger('change');
}
});
// Returning to page
$('.with-select input:text', thisQuestion).each(function(i) {
var thisCell = $(this).closest('.answer-item');
var inputText = $.trim($(this).val());
var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val();
$('select.inserted-select', thisCell).val(selectval);
});
// Clean-up styles
$('select.inserted-select', thisQuestion).css({
'max-width': '100%'
});
$('.with-select input:text', thisQuestion).css({
'position': 'absolute',
'left': '-9999em'
});
});
</script>
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Please Log in or Create an account to join the conversation.
If you can help me when you'll have time, I would really appreciate.
Marie-france
Please Log in or Create an account to join the conversation.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
- Posts: 12030
- Karma: 413
- Thank you received: 2195
Seriously ?marief99 wrote: If you can help me when you'll have time, I would really appreciate.

You can copy/paste yhe @Joffm method, if you need a professional service : contact a professional : www.limesurvey.com/support
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 .
An error happen ? Before make a new topic : remind the Debug mode .
Please Log in or Create an account to join the conversation.
LSG == Limesurvey Group file
LSQ == Limesurvey Question file
So yes, you can not import a whole survey file into your survey.
The LSS file is for you to have a look at it how it works and then implement it into your own survey. You could even export the question groups (as LSG) or questions (LSQ) that you need and then import them into your survey.
However, it make sense that you look at how Joffm did it and then implement it into your own survey. Depending on your survey structure you might have to adapt the script provided by Joffm.
I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Please Log in or Create an account to join the conversation.
Marie-France
Please Log in or Create an account to join the conversation.
One addition to holch's explanation.
Why do we prefer to attach LSS files?
LSS files you can import as a new survey without any preparation.
LSQ and LSG files you can import into an existing survey.
But now the crucial point.
LSQ and LSG are language dependent.
So, if I send a file created with base language "English" you can't import it into a survey that doesn't contain this language.
So in my opinion LSQ and LSG exports should only be used internally to copy them from one survey to a second, or to build a library of often used questions.
But here it is very frustrating if we get an LSQ export with an unknown base language.
All the best
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in or Create an account to join the conversation.
A friend helped me integrate the question as programmed by Joffm.
However, I wonder how to allow numeric responses only in the 3rd column of the table.
Also, how do you add a condition for the 3rd column to appear if and only if respondents answer "yes" to the 2nd question? (did you participate in the activity?)
Thank you in advance for your valuable advice!
Marie-France
Please Log in or Create an account to join the conversation.
the easy method is to validate
1. that there are only entries in third column if column 2 was answered "Yes":
Something like "Q1_Y001_X002!='Yes' and is_empty(Q1_Y001_X003)" ...
2. that there are only numeric entries in column 3 (here you may use the function "is_numeric") like "is_numeric(Q1_Y001_X003)"
https://manual.limesurvey.org/Expression_Manager_-_presentation#Implemented_functions
There might be a way to clear and set the third column to "readonly" until column 2 is "Yes", but that's beyond my capabilities.
I am not very familiar with javascript; and the provided script is not mine, but here from the forum and a little bit adapted by me..
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in or Create an account to join the conversation.