Hello everybody,
I tried to add checkboxes under multiple numeric input fields. I managed to accomplish this to a certrain degree by adding the following code to the question:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
var lastInput = $('input:text:last', thisQuestion);
var lastItem = $(lastInput).closest('div');
// Insert the check-box
$(lastItem).addClass('checkbox-item with-inserted-checkbox').append('<input type="checkbox" name="insertedInput" id="insertedInput" value=""><label for="insertedInput" class="checkbox-label control-label"></label>');
// Listener on the checkbox
$(':checkbox', lastItem).on('change', function(e) {
if($(this).is(':checked')) {
$('input:text', thisQuestion).not(lastInput).val('').trigger('keyup');
$(lastInput).val(100).trigger('keyup');
$('li.ls-group-dynamic', thisQuestion).hide();
}
else {
$('li.ls-group-dynamic', thisQuestion).show();
$(lastInput).val('').trigger('keyup');
}
});
});
</script>
<style type="text/css">.numeric-multi .with-inserted-checkbox input.form-control {
position: absolute;
left: -9999em;
}
.numeric-multi .with-inserted-checkbox label::before,
.numeric-multi .with-inserted-checkbox label::after {
margin: -7px 0 0 0;
}
</style>
After this the question looked like in the first screenshot ("without suffix")
The next step was to add suffixes, which concluded in the second screenshot ("with suffix")
I have one important and two optional issues:
1) I need to hide the suffix of the checkbox, as the "%" Symbol is only needed for the numeric input fields (This is the most important issue)
2) It would be wonderful to have not only one but two checkboxes at the bottom. The code I used only refers to the "last item", but I need the last two items.
3) The question only allows an input of at most 100%, which is displayed under the items ("Gesamt:"). Is it possible to display this value above the checkboxes and under the numeric input fields?
I have attached a sample survey and I use LimeSurvey Version 3.17.5+
Thanks a lot for every bit of help.