Welcome to the LimeSurvey Community Forum

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

Array question with answers in dropdown boxes

More
5 years 8 months ago #170145 by b1994mi
Replied by b1994mi on topic Array question with answers in dropdown boxes
Hi,

I have been using tpartner's javascript for providing dropdown options on array (texts). But, now I need something a bit specific. I need to make certain row readonly and force an answer that is different from the options provided by the dropdown.

What the respondents will think is that this readonly inputs are fixed because they need to use MRT for that journey.

Here is the mockup of what I need:
Warning: Spoiler!


I have attached my survey file with only the corresponding question group.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #170227 by tpartner
Replied by tpartner on topic Array question with answers in dropdown boxes
I don't think it's possible with a single array question as your "MRT" row is a moving target depending on the answers to the first two questions. I would do it with three array questions, styled with CSS to appear as one.

- One array for modes getting to MRT
- One (readonly) array for MRT
- One array for modes getting from MRT

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 8 months ago #170232 by b1994mi
Replied by b1994mi on topic Array question with answers in dropdown boxes
Hi,

I have found this thread and it is about two radio button question merged into one.

How to call the previous question? (assuming that I place the MRT in the middle)

Or is there any exact thread you can refer? It is a bit too complicated for me to implement the CSS :(

Thank you in advance.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #170236 by tpartner
Replied by tpartner on topic Array question with answers in dropdown boxes
It would be far easier to do it with CSS but the details would depend on your LimeSurvey version and theme.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 8 months ago #170276 by b1994mi
Replied by b1994mi on topic Array question with answers in dropdown boxes
Hi,

My Limesurvey version is Version 3.6.2+180406 and the theme is fruity. Is there any thing that I should notice if I ever needed the workaround to be done on another version and theme?

Thank you in advance.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #170278 by tpartner
Replied by tpartner on topic Array question with answers in dropdown boxes
- Assign Q1 a CSS class "merge-bottom".
- Assign Q2 CSS classes "merge-top merge-bottom".
- Assign Q3 a CSS class "merge-top".

Add something like this to custom.css in your extended theme:

Code:
.question-container.merge-bottom {
    margin-bottom: 0;
    border-bottom: 0 none;
}
 
.question-container.merge-bottom .answer-container {
    padding-bottom: 0;
}
 
.question-container.merge-top,
.question-container.merge-top .subquestion-list,
.question-container.merge-top .subquestion-list tbody tr:first-child > * {
    border-top: 0 none;
}
 
.question-container.merge-top .answer-container {
    padding-top: 0;
}
 
.question-container.merge-top .question-title-container,
.question-container.merge-top .question-valid-container,
.question-container.merge-top .subquestion-list thead {
  display: none;
}



Regarding other themes - you would need to explore the HTML and CSS affecting the layout to determine what is required.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 8 months ago #170411 by b1994mi
Replied by b1994mi on topic Array question with answers in dropdown boxes
Hi,

Thank you, it worked. But, a new problem arises. I need to force input the array fields. :(

So far I have used:
Code:
{middle_1_SQ001="MRT"}
{middle_1_SQ002=20}
{middle_1_SQ003=8000}
to force input, but it did not work. How is so?

Here is what it looks like:
Warning: Spoiler!


I have attached my survey file below.

Btw, I need to use 'for loop' to calculate time from one station to another and input in 'time (min)' for MRT. Should I just make a new thread or is there already a thread that asks the same question?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #170432 by tpartner
Replied by tpartner on topic Array question with answers in dropdown boxes
If you want to use Expression manager to set answers, you must place those statements in equation type questions positioned after the array.

Having said that, you could use JavaScript to set the answers as you render the inputs readonly.

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    $("#answer{SGQ}1_SQ001").val('MRT').trigger('keyup').prop("readonly",true);
    $("#answer{SGQ}1_SQ002").val(20).trigger('keyup').prop("readonly",true);
    $("#answer{SGQ}1_SQ003").val(8000).trigger('keyup').prop("readonly",true);
  });
</script>


Regarding your 'for loop' question - sorry, I have no idea what you are trying to do.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 8 months ago #170438 by b1994mi
Replied by b1994mi on topic Array question with answers in dropdown boxes
I see, I think this would be all that I need. I don't think the for loop is necessary anymore, so let's just forget it.

Thank you very much for your help. :)
The topic has been locked.
More
3 years 9 months ago #200227 by eglerapaliute
Replied by eglerapaliute on topic Array question with answers in dropdown boxes
Hi everyone,

I have tried doing arrays with dropdown list for quite a while. Couple questions:
1. Is it possible to make arrays with dd list without using java but with pre-existing features?

2. I do have two accounts, so one is managed by university and I cannot change settings (Version 4.1.14+) and another account is on me where im able to change settings (Version 3.22.14). Although I want and need to use server of uni account. Would I be able to do my question with my own version where I can add java script and after that successfully export to my uni account?

2. I still dont get how to do arrays with dd list even though I copy the entire code...
My "simple" plan is to have 1st column percentages/numbers give respondent to choose from and then have next 3 columns with free text. Is that possible?

Sorry for THAT long questions
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #200234 by tpartner
Replied by tpartner on topic Array question with answers in dropdown boxes
If you do not have permissions to insert JavaScript on the university server, you will not be able to import scripts developed in the 3.x server. As far as I know, they will be removed on importing and certainly will be removed when editing.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose