Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Merge dropdown and input numerical values - low code

  • julianna_tri
  • julianna_tri's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago #245861 by julianna_tri
Please help us help you and fill where relevant:
Your LimeSurvey version: Versão 3.28.30+220927
Own server or LimeSurvey hosting:  limesurvey.funai.gov.br/index.php?r=admin/survey/sa/listsurveys
Survey theme/template: 
==================

hello, I don't know javascript and I need to merge input numerical and dropdown list at the same question.
My goal is numerical input at x1, x3, x5 and x7 also having dropdown list around ten options. I do nee the sum of x1, x3, x5 and x7 values. 
Can someone help me?

thanks a lot. 



 
Attachments:

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago #245870 by Joffm
Hi,
there are really many, many examples here how to do this.
Like this. In the provided sample survey you find several examples
[url] forums.limesurvey.org/forum/can-i-do-thi...a-array-texts#189538 [/url]

Now, doing it like this you have to validate that there are no double "Elementos de despesa"

So in my opinion it is better to split the question
1. "multiple" question to select the elements
2. Either "multiple numerical input" or "array(text)" to enter the valores, using the array filter to only display the selected elementos 
Here both options. In the array you have the built-in option to show the sum.
 
The question is: What for do you need the sum?
Only to display it?
Or to use in in following questions to compare or limit some inputs?

Anyway: Use ExpressionManager to sum your values. 

And you should send a lss export of these questions, that we can imagine better, what you want to achieve.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • julianna_tri
  • julianna_tri's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago #245877 by julianna_tri
Replied by julianna_tri on topic Merge dropdown and input numerical values - low code
Thanks a lot. I couldn't do by myself the dropdowns changes. Maybe I follow your split suggestion. Look, Would you know how to set  a "group question" condition ??What about  a "couple question condition"?  Ex: if I have around 14 questions in a group but, at least, 10th, 12th and 14th has to be true.
I really need both . 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago - 1 year 2 months ago #245878 by Joffm
Hi,
at first
If we write

And you should send a lss export of these questions,

we mean: Copy the survey, remove everything not related to your problem, send this as lss export.
We do not want to go through hundreds of questions to find the place of your problem.

Second:
I do not understand what is so difficult to adapt the script of question Q1a in the sample survey.
This contains everything you would like to have.
You see this in the script (the only part you have to adapt)
Code:
        // 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_X004', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                                                    <option value="">Select...</option>\
                                                    <option value="1">Option 1</option>\
                                                    <option value="2">Option 2</option>\
                                                    <option value="3">Option 3</option>\
                                                    <option value="4">Option 4</option>\
                                                </select>'); 


You can imagine that X001 and X004 refer to the y-axis subquestion codes - as you see in the screenshot.
So just enter
Code:
        $('.answer-item.answer_cell_X1', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                                                    <option value="">- please, select -</option>\
                                                    <option value="1">Elemento 1</option>\
                                                    <option value="2">Elemento 2</option>\
                                                    <option value="3">Elemento 3</option>\
                                                    <option value="4">Elemento 4</option>\
                                                    <option value="5">Elemento 5</option>\
                                                    <option value="6">Elemento 6</option>\
                                                </select>'); 

for all cells X1, X3, X5 and X7

And as you see you run out of space.
So you could additionally set different column widths
with a second script and some css
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
    // Add a question class
    thisQuestion.addClass('custom-array');
 
    // Column-specific classes
    $('table.subquestion-list tr', thisQuestion).each(function(i) {
      $('th, td', this).each(function(i) {
        $(this).addClass('column-'+i);
      });
    });
  });
</script>
<style type="text/css">.custom-array table.subquestion-list col {
    width: auto !important;
  }
  .custom-array table.subquestion-list thead .column-0 {  width: 12%; }
  .custom-array table.subquestion-list thead .column-1 {  width: 14%; }
  .custom-array table.subquestion-list thead .column-2 {  width: 8%; }
  .custom-array table.subquestion-list thead .column-3 {  width: 14%; }
  .custom-array table.subquestion-list thead .column-4 {  width: 8%; }
  .custom-array table.subquestion-list thead .column-5 {  width: 14%; }
  .custom-array table.subquestion-list thead .column-6 {  width: 8%; }
  .custom-array table.subquestion-list thead .column-7 {  width: 14%; }
  .custom-array table.subquestion-list thead .column-8 {  width: 8%; }
</style>


which would result in
 
Well, as it is not necessary that all 4 elements have to be chosen, you have to validate that
there are not double elements
there is an input in "valor" if an element is selected and viceversa no input in valor if the element is not selected.

Therefore in my opinion the other solution is better.
Really easy to display the sum (you still did not explain what for you need it)
No check for doubles.
No check for "Both values (elemento & valor) have to be answered.
No javascript.

To finish

Would you know how to set  a "group question" condition ??What about  a "couple question condition"?

Not as long as you use this "outdated" condition builder. 
Use ExpressionManager. Much easier, mightier and more flexible.
This condition builder was implemented long before Expression Manager was implemented, about version 1.92.
With Condition Builder you only can create simple conditions.
Read the manual here
[url] www.limesurvey.org/manual/ExpressionScri...ons_and_Relevance.3F [/url]
Conditions : Condition Builder
Relevance: ExpressionManager (since version 5.0 called ExpressionScript)

Please, explain better how to set the conditions in your group.

Next:
You see that the display of question G4P2 with 8 columns is totally broken. Use less columns (6).
You imported an already existing group. You see that the question codes of Ativ 02 are a random sequence of characters now.
Meaning: You can't do this (or change all question codes afterwards)

Though each of your activities have 14 questions you shouldn't display the whole group on one page.
It is really cimbersome for the respondent to scroll and scroll.
A rule for online surveys is "One question per page".

You really should revise your layout.

But to repeat:
explain what means:

if I have around 14 questions in a group but, at least, 10th, 12th and 14th has to be true.

Does it mean: If one of the questions is not true (what is TRUE) the respondent is screened out?

Joffm


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 2 months ago by Joffm.

Please Log in to join the conversation.

  • julianna_tri
  • julianna_tri's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago #245971 by julianna_tri
Replied by julianna_tri on topic Merge dropdown and input numerical values - low code
I've been adjusting the layout by grouping the questions. I also set the "condition group" by using "(( ! is_empty(G3_ATIV1.NAOK))) and 1". However, I couldn't set the sum by the array as you suggested at the 'input numerical values' question type. COuld you please help me ?

Please Log in to join the conversation.

  • julianna_tri
  • julianna_tri's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago #245972 by julianna_tri
Replied by julianna_tri on topic Merge dropdown and input numerical values - low code
basically, i have 4 sum values (both numerical input questions) and i need sum them for a 5th result be viewyd by the respondents.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago #245973 by Joffm
Sorry, no.
Not without seeing what you exactly did.
lss export, please.

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago #245998 by Joffm

basically, i have 4 sum values (both numerical input questions) and i need sum them for a 5th result be viewyd by the respondents.

I do not understand this.

Here you get two solutions,
1. multiple numerical input  with two different ways to display the sum.
 
2. Array(text)
 

 

File Attachment:

File Name: limesurvey...8782.lss
File Size:34 KB


As said before, send the lss export.

Joffm


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose