Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Search Results (Searched for: multiple)
- Joffm
16 Jul 2023 08:49
Replied by Joffm on topic Multiple-choice table
Hi,
why didn't you answer the questions at the beginning?
Without further explanation from your side I'd say this is a simple "array(text)"
Maybe you want to have some predefined answers and want to use drop-downs.
If so, there are "hundreds" of examples in the forum.
Like here (lss with several examples)
[url] forums.limesurvey.org/forum/can-i-do-thi...a-array-texts#189538 [/url]
and here (with a multiple option)
[url] forums.limesurvey.org/index.php/forum/ca...list-in-array#239339 [/url]
But it is a bit useless to guess what you are really trying to achieve.
Please, explain more detailled.
Joffm
why didn't you answer the questions at the beginning?
Without further explanation from your side I'd say this is a simple "array(text)"
Maybe you want to have some predefined answers and want to use drop-downs.
If so, there are "hundreds" of examples in the forum.
Like here (lss with several examples)
[url] forums.limesurvey.org/forum/can-i-do-thi...a-array-texts#189538 [/url]
and here (with a multiple option)
[url] forums.limesurvey.org/index.php/forum/ca...list-in-array#239339 [/url]
But it is a bit useless to guess what you are really trying to achieve.
Please, explain more detailled.
Joffm
- Joffm
15 Jul 2023 21:46
Replied by Joffm on topic Fill in the blanks in a paragraph
So, you want something like this
Please, see here
[url] forums.limesurvey.org/index.php/forum/ca...down-box-within-text [/url]
But to be honest: I do not understand your question.
There is only one dropdown, but this gives many senseless phrases, like
"What how your job?"
"What New York your job?"
Please, explain more detailled what you expect the participants to do?
Joffm
Please, see here
[url] forums.limesurvey.org/index.php/forum/ca...down-box-within-text [/url]
But to be honest: I do not understand your question.
There is only one dropdown, but this gives many senseless phrases, like
"What how your job?"
"What New York your job?"
Please, explain more detailled what you expect the participants to do?
Joffm
- Perlette
14 Jul 2023 17:43
Multiple-choice table was created by Perlette
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hello everyone,
Is someone knows what can I do this table form with limesurvey ?
Thanks for your help.
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hello everyone,
Is someone knows what can I do this table form with limesurvey ?
Thanks for your help.
- tpartner
13 Jul 2023 16:24
Replied by tpartner on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
...and, updated workarounds docs -
manual.limesurvey.org/Workarounds:_Manip...meSurvey_version_6.x
- tpartner
13 Jul 2023 16:03
Replied by tpartner on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
If the employee count question is on a previous page...
1) Place sub-question relevance on the array rows to only show them if the employee count is above a certain number.
2) Use this modified script to add/remove rows. Changes in the script are:
- Exclude the irrelevant rows from the add/remove functions
- Use add/remove buttons instead of <div> elements
- Add variables to handle the button classes and styles
- Reset the inserted drop-down(s) when a row is hidden
- Generally clean up code for better efficiency
Sample survey attached:
1) Place sub-question relevance on the array rows to only show them if the employee count is above a certain number.
2) Use this modified script to add/remove rows. Changes in the script are:
- Exclude the irrelevant rows from the add/remove functions
- Use add/remove buttons instead of <div> elements
- Add variables to handle the button classes and styles
- Reset the inserted drop-down(s) when a row is hidden
- Generally clean up code for better efficiency
Code:
<script type="text/javascript" data-author="Tony Partner"> $(document).ready(function() { // A function to add or remove rows of an Array (Multi Flexible)(Text) question function varLengthArray(qID) { if ($('#question'+qID+'').length > 0) { var thisQuestion = $('#question'+qID); // The HTML content of the Add/Remove elements - modify as you wish var addContent = '[+] Add row'; var removeContent = '[-] Remove row'; // The classes for the Add/Remove elements - modify as you wish // See https://getbootstrap.com/docs/5.0/getting-started/introduction/ var addClasses = 'inserted-button add btn btn-success'; var removeClasses = 'inserted-button remove btn btn-danger'; // The styles for the Add/Remove elements - modify as you wish // These could be placed in your custom.css file. var addStyles = 'margin:10px 0 10px 10px; padding:1px 5px; text-align:center; width:auto; cursor:pointer; float:left;'; var removeStyles = 'margin:10px 0 10px 10px; padding:1px 5px; text-align:center; width:auto; cursor:pointer; float:left;'; // Insert the buttons $( 'table.ls-answers', thisQuestion).after('<div class="button-wrapper">\ <button type="button" class="'+addClasses+'" style="'+addStyles+'">'+addContent+'</button>\ <button type="button" class="'+removeClasses+'" style="display: none; '+removeStyles+'">'+removeContent+'</button>\ </div>'); // Listeners on the buttons $('.inserted-button.add', thisQuestion).on('click', function (event) { addRow(); }); $('.inserted-button.remove', thisQuestion).on('click', function (event) { removeRow(); }); // Define the relevant rows var relevantRows = $('tr.subquestion-list:not(.ls-irrelevant)', thisQuestion); // Function to add a row, show the "Remove" element and hide the "Add" element if all rows are shown function addRow() { $('[data-visible="false"]:first', thisQuestion).attr('data-visible', 'true').show(); $('.inserted-button.remove', thisQuestion).show(); console.log($('[data-visible="true"]', thisQuestion).length+' == '+$(relevantRows).length - 1); if ($('[data-visible="false"]', thisQuestion).length == 0) { $('.inserted-button.add', thisQuestion).hide(); } $('.inserted-button.add', thisQuestion).blur(); } // Function to remove a row, clear the contents of the removed row, // show the "Add" element if the last row is hidden and hide the "Remove" element if only the first row is shown function removeRow() { $('[data-visible="true"]:last input:text', thisQuestion).val('').trigger('keyup'); $('[data-visible="true"]:last .inserted-select', thisQuestion).val('').trigger('change'); $('[data-visible="true"]:last', thisQuestion).attr('data-visible', 'false').hide(); $('.inserted-button.add', thisQuestion).show(); if ($('[data-visible="true"]', thisQuestion).length == 0) { $('.inserted-button.remove', thisQuestion).hide(); } $('.inserted-button.remove', thisQuestion).blur(); } // Initially hide all except first row or any rows with populated inputs $(relevantRows).slice(1).each(function(i) { $( this ).attr('data-visible', 'false').hide(); $('input[type=text]', this).each(function(i) { if ($.trim($(this).val()) != '') { $(this).closest('tr').attr('data-visible', 'true').show(); $('.inserted-button.remove', thisQuestion).show(); } }); }); } } // Call the function with a question ID varLengthArray({QID}); }); </script>
Sample survey attached:
- rrscw
13 Jul 2023 08:26
Replied by rrscw on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
There's one more thing I wanted to ask. Can I restrict user from adding more rows after a certain number. Like, let's say they entered 5 total number of employees. Can I do something so that after entering name of 5 members they cannot add any using the add row button?
- rrscw
13 Jul 2023 07:16 - 13 Jul 2023 07:16
Replied by rrscw on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
That works perfectly. !
I'm quite new to this and my survey wasn't active yet so I only realized that the textbox won't work after you pointed that out. I should've known.
Using the array text with dropdown is an excellent approach, I'm gonna use this one instead.
Thank you so much!
I'm quite new to this and my survey wasn't active yet so I only realized that the textbox won't work after you pointed that out. I should've known.
Using the array text with dropdown is an excellent approach, I'm gonna use this one instead.
Thank you so much!
- Joffm
12 Jul 2023 15:37
Replied by Joffm on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
Here a screenshot of my last proposal.
Array(text) with dopdown cells, dynamic insertion of rows and customized column widths
Joffm
Array(text) with dopdown cells, dynamic insertion of rows and customized column widths
Joffm
- Joffm
12 Jul 2023 13:54 - 12 Jul 2023 14:25
Replied by Joffm on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
Hi
This script is meant for array(text).
So stay to your solution to show the next row when one row is completed. (or adapt the script)
But as I asked before, how do you insert the text inputs.
As you do it now it will never work. How do you store the input?
But there is another example in the forum
[url] forums.limesurvey.org/index.php/forum/ca...ith-radiolist#223422 [/url]
Another idea:
Use an array(text)
First column you enter the text
Second column you display a dropdown with the options.
There are many exampüles in the forum how to insert dropdowns in an array(texct)
And:
Do NOT change {QID}
This is a Limesurvey variable that always contains the actual question ID.
What you entered is the question CODE, quite different
Joffm
This script is meant for array(text).
So stay to your solution to show the next row when one row is completed. (or adapt the script)
But as I asked before, how do you insert the text inputs.
As you do it now it will never work. How do you store the input?
But there is another example in the forum
[url] forums.limesurvey.org/index.php/forum/ca...ith-radiolist#223422 [/url]
Another idea:
Use an array(text)
First column you enter the text
Second column you display a dropdown with the options.
There are many exampüles in the forum how to insert dropdowns in an array(texct)
And:
Do NOT change {QID}
This is a Limesurvey variable that always contains the actual question ID.
What you entered is the question CODE, quite different
Joffm
- rrscw
12 Jul 2023 13:36
This is the code you provided.
$(document).ready(function() {
// A function to add or remove rows of an Array (Multi Flexible)(Text) question
function varLengthArray(qID) {
if ($('#question'+qID+'').length > 0) {
// The HTML content of the Add/Remove elements - modify as you wish
var addContent = '[+] add row';
var removeContent = '[-] remove row';
// Create the Add and Remove elements & insert them
var el1 = document.createElement('div');
el1.setAttribute('id','addButton'+qID);
el1.setAttribute('class','btn btn-primary');
document.body.appendChild(el1);
var el2 = document.createElement('div');
el2.setAttribute('id','removeButton'+qID);
el2.setAttribute('class','btn btn-primary');
document.body.appendChild(el2);
// Move them to after the array
$( 'div#addButton'+qID ).appendTo($( '#question' + qID + ' table.ls-answers' ).parent());
$( 'div#removeButton'+qID ).appendTo($( '#question' + qID + ' table.ls-answers' ).parent());
// Insert their HTML
$( 'div#addButton'+qID ).html( addContent );
$( 'div#removeButton'+qID ).html( removeContent );
// Style the elements - you can modify here if you wish
$( 'div#addButton'+qID ).css({
'margin':'10px 0 0 10px',
'padding':'1px',
'text-align':'center',
'width':'auto',
'cursor':'pointer',
'float':'left'
});
$( 'div#removeButton'+qID ).css({
'margin':'10px 0 0 10px',
'padding':'1px',
'text-align':'center',
'width':'auto',
'cursor':'pointer',
'float':'left'
});
// Initially hide the Remove element
$( 'div#removeButton'+qID ).hide();
// Call the functions below when clicked
$( 'div#addButton'+qID ).click(function (event) {
addRow(qID);
});
$( 'div#removeButton'+qID ).click(function (event) {
removeRow(qID);
});
// Function to add a row, also shows the Remove element and hides the
//Add element if all rows are shown
function addRow(qID) {
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = $( arrayRow ).size() - 1;
$( arrayRow + '[name="hidden"]:first' ).attr('name', 'visible').show();
$( 'div#removeButton'+qID ).show();
if ( $( arrayRow + ':eq(' + rowCount + ')' ).attr('name') == 'visible' ) {
$( 'div#addButton'+qID ).hide();
}
}
// Function to remove a row, also clears the contents of the removed row,
// shows the Add element if the last row is hidden and hides the Remove
// element if only the first row is shown
function removeRow(qID) {
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = $( arrayRow ).size() - 1;
$( arrayRow + '[name="visible"]:last input[type="text"]' ).val('');
$( arrayRow + '[name="visible"]:last' ).attr('name', 'hidden').hide();
$( 'div#addButton'+qID ).show();
if ( $( arrayRow + ':eq(1)' ).attr('name') == 'hidden' ) {
$( 'div#removeButton'+qID ).hide();
}
}
// Just some initialization stuff
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = '';
// Initially hide all except first row or any rows with populated inputs
$( arrayRow ).each(function(i) {
if ( i > 0 ) {
// We also need to give the hidden rows a name cause IE doesn't
// recognize jQuery :visible selector consistently
$( this ).attr('name', 'hidden').hide();
$('input[type=text]', this).each(function(i) {
if ($(this).attr('value') != '') {
$(this).parents('tbody:eq(0)').attr('name', 'visible').show();
$( 'div#removeButton'+qID ).show();
}
});
rowCount = i;
}
});
}
}
// Call the function with a question ID
varLengthArray({QID});
});
</script>
I tried the code you provided in that link and also added the relevance equation and these are the issues.
Replied by rrscw on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
Thank you for the very quick reply !
This is the code you provided.
$(document).ready(function() {
// A function to add or remove rows of an Array (Multi Flexible)(Text) question
function varLengthArray(qID) {
if ($('#question'+qID+'').length > 0) {
// The HTML content of the Add/Remove elements - modify as you wish
var addContent = '[+] add row';
var removeContent = '[-] remove row';
// Create the Add and Remove elements & insert them
var el1 = document.createElement('div');
el1.setAttribute('id','addButton'+qID);
el1.setAttribute('class','btn btn-primary');
document.body.appendChild(el1);
var el2 = document.createElement('div');
el2.setAttribute('id','removeButton'+qID);
el2.setAttribute('class','btn btn-primary');
document.body.appendChild(el2);
// Move them to after the array
$( 'div#addButton'+qID ).appendTo($( '#question' + qID + ' table.ls-answers' ).parent());
$( 'div#removeButton'+qID ).appendTo($( '#question' + qID + ' table.ls-answers' ).parent());
// Insert their HTML
$( 'div#addButton'+qID ).html( addContent );
$( 'div#removeButton'+qID ).html( removeContent );
// Style the elements - you can modify here if you wish
$( 'div#addButton'+qID ).css({
'margin':'10px 0 0 10px',
'padding':'1px',
'text-align':'center',
'width':'auto',
'cursor':'pointer',
'float':'left'
});
$( 'div#removeButton'+qID ).css({
'margin':'10px 0 0 10px',
'padding':'1px',
'text-align':'center',
'width':'auto',
'cursor':'pointer',
'float':'left'
});
// Initially hide the Remove element
$( 'div#removeButton'+qID ).hide();
// Call the functions below when clicked
$( 'div#addButton'+qID ).click(function (event) {
addRow(qID);
});
$( 'div#removeButton'+qID ).click(function (event) {
removeRow(qID);
});
// Function to add a row, also shows the Remove element and hides the
//Add element if all rows are shown
function addRow(qID) {
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = $( arrayRow ).size() - 1;
$( arrayRow + '[name="hidden"]:first' ).attr('name', 'visible').show();
$( 'div#removeButton'+qID ).show();
if ( $( arrayRow + ':eq(' + rowCount + ')' ).attr('name') == 'visible' ) {
$( 'div#addButton'+qID ).hide();
}
}
// Function to remove a row, also clears the contents of the removed row,
// shows the Add element if the last row is hidden and hides the Remove
// element if only the first row is shown
function removeRow(qID) {
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = $( arrayRow ).size() - 1;
$( arrayRow + '[name="visible"]:last input[type="text"]' ).val('');
$( arrayRow + '[name="visible"]:last' ).attr('name', 'hidden').hide();
$( 'div#addButton'+qID ).show();
if ( $( arrayRow + ':eq(1)' ).attr('name') == 'hidden' ) {
$( 'div#removeButton'+qID ).hide();
}
}
// Just some initialization stuff
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = '';
// Initially hide all except first row or any rows with populated inputs
$( arrayRow ).each(function(i) {
if ( i > 0 ) {
// We also need to give the hidden rows a name cause IE doesn't
// recognize jQuery :visible selector consistently
$( this ).attr('name', 'hidden').hide();
$('input[type=text]', this).each(function(i) {
if ($(this).attr('value') != '') {
$(this).parents('tbody:eq(0)').attr('name', 'visible').show();
$( 'div#removeButton'+qID ).show();
}
});
rowCount = i;
}
});
}
}
// Call the function with a question ID
varLengthArray({QID});
});
</script>
I tried the code you provided in that link and also added the relevance equation and these are the issues.
- The relevance equation separately work fine, when one subquestion's radio button is clicked another question automatically appears.
- When I paste the code exactly. the buttons do appear. When add button is clicked the remove button appears as well. However, it does not actually add or remove any subquestions and the subquestions are just displaying the behavior I mentioned in first point. They are appearing when one subquestion is not empty due to the relevance eq and not the buttons themselves.
- when I change this line [varLengthArray({QID});] and add my question's id which is G04Q17, the buttons disappear as well.
But you did not show us which script you used to insert the text boxes.
- Joffm
12 Jul 2023 11:20
Replied by Joffm on topic Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306
Hi,
maybe this is helpful
[url] forums.limesurvey.org/index.php/forum/de...o-add-new-answer-row [/url]
But you did not show us which script you used to insert the text boxes.
In such cases it is always the best to create a small sample of your work and send the lss export,
This helps us to understand better what you intend and what you did so far.
Joffm
maybe this is helpful
[url] forums.limesurvey.org/index.php/forum/de...o-add-new-answer-row [/url]
But you did not show us which script you used to insert the text boxes.
In such cases it is always the best to create a small sample of your work and send the lss export,
This helps us to understand better what you intend and what you did so far.
Joffm
- rrscw
12 Jul 2023 07:36 - 12 Jul 2023 07:41
Multiple Subquestions that can be added at the time of survey Version 6.1.5+2306 was created by rrscw
Hello,
I'm using an array question type where I have made the subquestion for entering name of a group of people while they can select their qualification from the radio buttons in the Answer Options. I'll attach a picture so you can get the idea of what I'm talking about.
Now, since I want to add name and qualification of people in the survey, I want that the subquestion could be added at the time of survey like we add tasks in a to do list where we can add new task or delete it. Similarly, I want that the user can add names and qualification of all staff members.
If this cannot be implemented,
The number of entries to be added actually depends on a previous question where I am asking the number of staff members.
There is a maximum number of members.
Even if I add subquestion with textbox for lets say 20 people but the entry done at the time of survey of staff members is only 10 then I want the other 10 extra subquestions to be hidden from user when they get to that part of survey. It should be according to the answer of the previous question asking the number of staff members.
Can any of this be done with Limesurvey. Is there a feature or add on that I can refer to ?
I'm using a self-hosted limesurvey that is offline.
This is my version : LimeSurvey Community Edition Version 6.1.5+230626
Please tell me if you need any other information.
I'm using an array question type where I have made the subquestion for entering name of a group of people while they can select their qualification from the radio buttons in the Answer Options. I'll attach a picture so you can get the idea of what I'm talking about.
Now, since I want to add name and qualification of people in the survey, I want that the subquestion could be added at the time of survey like we add tasks in a to do list where we can add new task or delete it. Similarly, I want that the user can add names and qualification of all staff members.
If this cannot be implemented,
The number of entries to be added actually depends on a previous question where I am asking the number of staff members.
There is a maximum number of members.
Even if I add subquestion with textbox for lets say 20 people but the entry done at the time of survey of staff members is only 10 then I want the other 10 extra subquestions to be hidden from user when they get to that part of survey. It should be according to the answer of the previous question asking the number of staff members.
Can any of this be done with Limesurvey. Is there a feature or add on that I can refer to ?
I'm using a self-hosted limesurvey that is offline.
This is my version : LimeSurvey Community Edition Version 6.1.5+230626
Please tell me if you need any other information.
- Joffm
09 Jul 2023 14:54
Replied by Joffm on topic Can I use Google Charts to graph data in Limesurvey?
- amilcar_pg
05 Jul 2023 19:31
Replied by amilcar_pg on topic Create a masked question that checks if all multiple choices have the same answe
It worked flawlessly Joffm! Huge thanks!
- Joffm
05 Jul 2023 18:44 - 05 Jul 2023 18:45
Replied by Joffm on topic Create a masked question that checks if all multiple choices have the same answe
Hi,
read the manual about implemented functions
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]
where you find the functions "count()" and "countif()"
Now your equation will count each of your 5 answer options, like
countif("1",that.G01Q02.NAOK)
countif("2",that.G01Q02.NAOK)
...
If one of these counts is equal to 5, or more general (that it matches each number of subquestions) to "count(that.G01Q02)" you set the result to 1, else to 0.
And set your quota on this equation.
So:
{if(countif("1",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("2",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("3",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("4",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("5",that.G01Q02.NAOK)==count(that.G01Q02.NAOK),1,0)}
Of course, you should use numerical codes- as I did. In your analysis you usually want to calculate some statistical measures, like mean, std.deviation, etc and also run some tests, like t-Test or ANOVA.
And really: the mean of "AO01" and "AO04" is not "AO02.5".
Joffm
read the manual about implemented functions
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]
where you find the functions "count()" and "countif()"
Now your equation will count each of your 5 answer options, like
countif("1",that.G01Q02.NAOK)
countif("2",that.G01Q02.NAOK)
...
If one of these counts is equal to 5, or more general (that it matches each number of subquestions) to "count(that.G01Q02)" you set the result to 1, else to 0.
And set your quota on this equation.
So:
{if(countif("1",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("2",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("3",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("4",that.G01Q02.NAOK)==count(that.G01Q02.NAOK) or countif("5",that.G01Q02.NAOK)==count(that.G01Q02.NAOK),1,0)}
Of course, you should use numerical codes- as I did. In your analysis you usually want to calculate some statistical measures, like mean, std.deviation, etc and also run some tests, like t-Test or ANOVA.
And really: the mean of "AO01" and "AO04" is not "AO02.5".
Joffm