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

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 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="http://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="http://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="http://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="http://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="http://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="http://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="http://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.

Lime-years ahead

Online-surveys for every purse and purpose