Welcome to the LimeSurvey Community Forum

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

automatically fill day of week, based on respondents fill in the other form

More
4 years 2 months ago - 4 years 2 months ago #216965 by MAXINE321319
Hi all,
I would like to 

File Attachment:

File Name: New Text Document.txt
File Size:11.79 KB
ask help from you, I am doing a choice survey, in this context, I will show the day to the week to respondents, 
How can I make the survey can automatically fill the day of the week in the 8 fill fields (next 8 days), based on the respondent fill the day of today?
for example, in the choice list, there are Monday to Sunday (7 days of the week), respondents need to first choose the day of today, and then the survey can automatically fill the following 8 days.
for example: choose "Friday" for today.  Then the survey automatically fills the next 8 days, which should be: Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
will appreciate it a lot if you will help, attached is the HTML I have for now. 

Thank you! 
Last edit: 4 years 2 months ago by MAXINE321319.
The topic has been locked.
More
4 years 2 months ago - 4 years 2 months ago #216967 by Joffm
Hi,
please, only send lss exports of your survey (the relevant questions)

Or, at least, show a screenshot how this second question looks like. What type of question is it?
I could imagine it is some kind of an array, where the subquestions are dynamically filled with these following days.

Joffm

And do not forget to mention the LimeSurvey version you are using.

By the way:
The easiest solution would be to display the following 8 dates.
In this case it is not necessary to select the current day; the current date you get by the function "date".
And you avoid the translatio of the days in multilingual surveys

And also: What is your goal?
Do you want to know what people do, eat, buy, ... on Monday, on Tuesday, ... or do you want to know what people do the next day, the over next day, ...?
This is important. Because you always have to consider how the database will look like. So you may ease your analysis without a lot of restructuring the database.
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 2 months ago by Joffm.
The topic has been locked.
More
4 years 2 months ago #216968 by Joffm
Here a quick example without javascript (only a few equations). 

File Attachment:

File Name: limesurvey...7832.lss
File Size:29.12 KB
 

   


Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
4 years 2 months ago #216970 by MAXINE321319
Dear Joffm,

Thank you so much! Then you remind me that we only need show the following 8 dates, based on the actual dates of the respondents filling the questionnaires. 

The goal is, to see what people do the next day, the over next day... the questions or the choice that the respondents will face is: chose the day in the following 8 days, that you will do the "activity 1", for example, grocery shopping activity.  we assume that respondents will have different preferences for a different day of the week, and their history activity participation and some assumed systems varied day contexts (e.g. weather).  In other words, the choice task is a "table", in which, every row is a day: and shows the day of the week, the weather, and other day contexts of the day, in every final column of the row there is a checkbox, respondents can click to represent their choices to do the "activity 1" on the day, they can click multi-days in the 8 days. 

Actually, there are other questions: after their choice, they will be asked on which day(s), you will do the next "activity 2",  say: social. in the similar tables (day contexts, etc), but now, the previous choice of the "activity 1" on the last page, will be also auto-fill on the day of the respondent choice. 

So, could you please help me to auto-fill the next 8 days in the table?   and may also help me to auto-fill the previous choice days of last activities? there are 4-5 activities, respondents need to plan on which days to do them in the 8 days one by one, facing the day context table. 

please look at the Html below, which  I have so far:  thank you!
file:///C:/Users/20171389/Dropbox/2021/limesurvey/table.HTML

best regards,
Max
 
The topic has been locked.
More
4 years 2 months ago #216971 by Joffm
Hi, 
did you import the sample survey I provided?

Here is another example without the equations.
 

File Attachment:

File Name: limesurvey...6886.lss
File Size:26.03 KB


This way you do not store the names of the days in the database.
But this is not necessary as you have the current day stored.

But you are not very clear here

respondents will have different preferences for a different day of the week 


Yes, this will be true?
But doesn't it mean, you want to know, what they do on Monday, what on Saturday?
The way you ask this question, is different. You ask, what do you do tomorrow (without knowing which day it is).

Imagine an EXCEL sheet with seven columns
1. option
You save the responses for "Monday" in the 1st column, the responses for "Tuesday" in the 2nd, ...
So you can analyse easily what people do on the different days of the week.

2. option
You save the responses of the 1st following day in the 1st column, the 2nd following day in the 2nd column, ...
Now you have the responses for "Monday" spread over all seven columns and you will have to restructure before you are able to analyze it.

At the moment my examples show the 2nd option.


And what shall we do with your HTMl, which contains some css- and js-files located on your environment.
This forum deals with LimeSurvey.
So please, provide a lss export of your LimeSurvey survey.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
4 years 2 months ago #216972 by MAXINE321319
the version of LimeSurvey is Version 3.25.21, it seems I can not import the sample survey you provided. cause the verison problem?
The topic has been locked.
More
4 years 2 months ago #216973 by MAXINE321319
because I do not familiar with the LimeSurvey, and I just tried to use HTML and Javascript to have my choice task...and then apply the "source" button to add my "HTML and Javascript ", and I even do not familiar with "HTML and Javascript, CSS.... anyway, thanks for your help, and just please let me know if there is any stuff i did wrong.
The topic has been locked.
More
4 years 2 months ago #216974 by Joffm

it seems I can not import the sample survey you provided


Why? Was there an error message? Please, show it.

Usually you import by clicking this button, select the lss file and click "import survey"
 



If you do not see this button in the main menue you might not have rights to import. Ask the admin.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
4 years 2 months ago #216975 by MAXINE321319
Oh, I imported your example by "import a question"
the file should be .lsq
There is no button to "import a survey ", maybe I need to ask the Admin.

can I import your example by import a question? I already fill all the basic questions in the LimeSurvey system. such as: what is your age, etc.

now I am dealing with the stated choice experiment part, as I said, ask respondents to make choice in the 8 days context. so, I think maybe I can just import the experiment ( 8 days contexts situations) as a question.
how do you think?

In conclusion, I need to show the choice set of the days and ask respondents to choose. the question is a table, shows the day's situations, and respondents can choose the days in the table. I do not know how to add an image to show you in the forum.
The topic has been locked.
More
4 years 2 months ago #216977 by Joffm
If you can import a question I think you can import a group as well.

I will send an lsg export (lsg = LimeSurvey Group) later.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
4 years 2 months ago #216978 by Joffm
And here the lsg export
 

File Attachment:

File Name: limesurvey...3203.lsg
File Size:11.69 KB


Base language is "English".
Because lsq and lsg exports are language sensitive, we usually ask for lss exports.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
4 years 2 months ago #216985 by MAXINE321319
Hi Joffm,

I import your lsq, thanks.  However, I do not know how to adjust it based on my experiment background, so could you please help me to realize the automatically fill the 8 days in my HTML (attached)?    is it attached right? 

Thanks 
Maxine 
The topic has been locked.
More
4 years 2 months ago #216998 by Joffm
Hi,
I am still wondering about your HTML script.
If you are using LimeSurvey to run a survey you have to use the built-in question types to store the data in a database.
So read the manual to find the appropriate question type and the forum to see a lot of workarounds to adapt the look & feel.

In your case I propose an array(numbers) because in my opinion the question is a multiple question. (People may select more than one activity).

Then you can create a table in the question text to show the options and beneath the (one) subquestion of the array(number) with checkbox layout.
The gap between question text and checkbox row is removed by the css.
Like this
 

And the HTML code of the table is here:
Code:
<p> </p>
 
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse;" width="100%">
    <tbody>
        <tr>
            <td style="text-align: left;font-size:12pt" width="30%">Day of week </td>
            <td class="theader">{if(Q1a==1,"Tuesday",if(Q1a==2,"Wednesday",if(Q1a==3,"Thursday",if(Q1a==4,"Friday",if(Q1a==5,"Saturday",if(Q1a==6,"Sunday","Monday"))))))}</td>
            <td class="theader">{if(Q1a==7,"Tuesday",if(Q1a==1,"Wednesday",if(Q1a==2,"Thursday",if(Q1a==3,"Friday",if(Q1a==4,"Saturday",if(Q1a==5,"Sunday","Monday"))))))}</td>
            <td class="theader">{if(Q1a==6,"Tuesday",if(Q1a==7,"Wednesday",if(Q1a==1,"Thursday",if(Q1a==2,"Friday",if(Q1a==3,"Saturday",if(Q1a==4,"Sunday","Monday"))))))}</td>
            <td class="theader">{if(Q1a==5,"Tuesday",if(Q1a==6,"Wednesday",if(Q1a==7,"Thursday",if(Q1a==1,"Friday",if(Q1a==2,"Saturday",if(Q1a==3,"Sunday","Monday"))))))}</td>
            <td class="theader">{if(Q1a==4,"Tuesday",if(Q1a==5,"Wednesday",if(Q1a==6,"Thursday",if(Q1a==7,"Friday",if(Q1a==1,"Saturday",if(Q1a==2,"Sunday","Monday"))))))}</td>
            <td class="theader">{if(Q1a==3,"Tuesday",if(Q1a==4,"Wednesday",if(Q1a==5,"Thursday",if(Q1a==6,"Friday",if(Q1a==7,"Saturday",if(Q1a==1,"Sunday","Monday"))))))}</td>
            <td class="theader">{if(Q1a==2,"Tuesday",if(Q1a==3,"Wednesday",if(Q1a==4,"Thursday",if(Q1a==5,"Friday",if(Q1a==6,"Saturday",if(Q1a==7,"Sunday","Monday"))))))}</td>
        </tr>
        <tr>
            <td style="background-color:#c1c1c1;text-align: left;font-size:12pt">Week sales</td>
            <td class="tbody">Attribute 1</td>
            <td class="tbody">Attribute 1</td>
            <td class="tbody">grocery shopping sales: 30% off</td>
            <td class="tbody">Attribute 1</td>
            <td class="tbody">Attribute 1</td>
            <td class="tbody">Attribute 1</td>
            <td class="tbody">Attribute 1</td>
        </tr>
        <tr>
            <td style="background-color:#c1c1c1;text-align: left;font-size:12pt">Mandatory activities</td>
            <td class="tbody">work</td>
            <td class="tbody">work</td>
            <td class="tbody">work</td>
            <td class="tbody">no work</td>
            <td class="tbody">no work</td>
            <td class="tbody">work and pick off</td>
            <td class="tbody">work</td>
        </tr>
        <tr>
            <td style="background-color:#c1c1c1;text-align: left;font-size:12pt">Weather</td>
            <td class="tbody"><svg class="bi bi-brightness-high" color="red" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path> </svg></td>
            <td class="tbody"><svg class="bi bi-brightness-high" color="red" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path> </svg></td>
            <td class="tbody"><svg class="bi bi-cloud-drizzle" color="blue" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M4.158 12.025a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm6 0a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm-3.5 1.5a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm6 0a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 1 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm.747-8.498a5.001 5.001 0 0 0-9.499-1.004A3.5 3.5 0 1 0 3.5 11H13a3 3 0 0 0 .405-5.973zM8.5 2a4 4 0 0 1 3.976 3.555.5.5 0 0 0 .5.445H13a2 2 0 0 1 0 4H3.5a2.5 2.5 0 1 1 .605-4.926.5.5 0 0 0 .596-.329A4.002 4.002 0 0 1 8.5 2z"></path> </svg></td>
            <td class="tbody"><svg class="bi bi-cloud-drizzle" color="blue" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M4.158 12.025a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm6 0a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm-3.5 1.5a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm6 0a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 1 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm.747-8.498a5.001 5.001 0 0 0-9.499-1.004A3.5 3.5 0 1 0 3.5 11H13a3 3 0 0 0 .405-5.973zM8.5 2a4 4 0 0 1 3.976 3.555.5.5 0 0 0 .5.445H13a2 2 0 0 1 0 4H3.5a2.5 2.5 0 1 1 .605-4.926.5.5 0 0 0 .596-.329A4.002 4.002 0 0 1 8.5 2z"></path> </svg></td>
            <td class="tbody"><svg class="bi bi-cloudy" color="dark" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M13.405 8.527a5.001 5.001 0 0 0-9.499-1.004A3.5 3.5 0 1 0 3.5 14.5H13a3 3 0 0 0 .405-5.973zM8.5 5.5a4 4 0 0 1 3.976 3.555.5.5 0 0 0 .5.445H13a2 2 0 0 1-.001 4H3.5a2.5 2.5 0 1 1 .605-4.926.5.5 0 0 0 .596-.329A4.002 4.002 0 0 1 8.5 5.5z"></path> </svg></td>
            <td class="tbody"><svg class="bi bi-cloudy" color="dark" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M13.405 8.527a5.001 5.001 0 0 0-9.499-1.004A3.5 3.5 0 1 0 3.5 14.5H13a3 3 0 0 0 .405-5.973zM8.5 5.5a4 4 0 0 1 3.976 3.555.5.5 0 0 0 .5.445H13a2 2 0 0 1-.001 4H3.5a2.5 2.5 0 1 1 .605-4.926.5.5 0 0 0 .596-.329A4.002 4.002 0 0 1 8.5 5.5z"></path> </svg></td>
            <td class="tbody"><svg class="bi bi-cloud-drizzle" color="blue" fill="currentColor" height="16" viewbox="0 0 16 16" width="16" xmlns="https://www.w3.org/2000/svg"> <path d="M4.158 12.025a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm6 0a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm-3.5 1.5a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 0 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm6 0a.5.5 0 0 1 .316.633l-.5 1.5a.5.5 0 1 1-.948-.316l.5-1.5a.5.5 0 0 1 .632-.317zm.747-8.498a5.001 5.001 0 0 0-9.499-1.004A3.5 3.5 0 1 0 3.5 11H13a3 3 0 0 0 .405-5.973zM8.5 2a4 4 0 0 1 3.976 3.555.5.5 0 0 0 .5.445H13a2 2 0 0 1 0 4H3.5a2.5 2.5 0 1 1 .605-4.926.5.5 0 0 0 .596-.329A4.002 4.002 0 0 1 8.5 2z"></path> </svg></td>
        </tr>
    </tbody>
</table>

And a bit of css.
Code:
<style type="text/css">.ls-heading { display:none; }
.question-title-container { padding-bottom: 0; }
.answer-container { padding-top: 0; }
.theader {
   text-align: center;
   vertical-align:middle;
   padding-top:10px;
   padding-bottom:10px;
   background-color:#308737;
   color:#fff;
   font-size:14pt;
   font-weight:bold;
   width:10%;
}
.tbody {
   text-align: center;
   vertical-align:middle;
   padding-top:5px;
   padding-bottom:5px;
   background-color:#f2f2f2;
   color:black;
   font-size:11pt;
   font-weight:bold;
   width:10%;
}
</style>
 
What about this "mandatory acticities" row?
Doesn't the "work / no work" option depend on the day?
Now you have fixed rows, but the day of week changes according to the selected "current day".

Joffm

Later I will send the example.
And because you are not able to import lss exports one recommandation.

Create a free account of LimeSurvey here.
Then you may import surveys, play around, learn and export only questions (lsq) or groups (lsg) to import into the survey in your real environment.
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose