- Posts: 12785
- Thank you received: 3940
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
creating a table using javascript and the options are based previous answer
- Joffm
- Offline
- LimeSurvey Community Team
So you should be able to import.
But nevertheless, here again.
In about an hour I show you again the script.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- jelo
- Offline
- Platinum Member
- Posts: 5070
- Thank you received: 1263
Perhaps the file download was incomplete or the cloud version has a bug (it's not 100% identically to the community version.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
- Posts: 45
- Thank you received: 0
I have known the reason. because the limesurvey of mine is a group account, so I have to create a new account for open the file you sent to me, and the new account is version 5.xx. Now, I just use other version 3 to try it and it could be imported. but it still has problem and now I am not sure it is why. I am trying to solve it.
from the first picture, this is the command from you and it shows undefined variable ,so I change it to my vatiable from ptm_1 to ptransportmode_PT1, but the errors appear more, shown as second picture. and the last picture is the command after I changed the variable name.
Best,
Qiang
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
- Posts: 45
- Thank you received: 0
thanks for your reply. you are right, the cause is version. and then I think the HTML editor also play a important role.
Best,
Qiang
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12785
- Thank you received: 3940
But usually the TUE Installation works fine.
There were a lot of questions of several students in the past.
Well, here the script:
First:
I renamed
the question "ptransportmode" to "ptm"
the subquestions "PT1".. "PT5" to 1,2,3,4,5
In this script only items that were selected in ptm are displayed in the array.
If this is not the correct understanding and only the "not selected" are displayed,
either switch "hidden","tdn/f"
or change the condition from "==" to "!="
There are nested quotes only in the section "Move the radios". Keep an eye on them.
<table style="border:0;padding:0;border-collapse:collapse;color:#000;width:100%"> <thead> <tr> <td class="td1">Which of the following are the BEST OPTIONS for you?</td> <td class={if(ptm_1=="Y","tdf","hidden")}> </td> <td class={if(ptm_1=="Y","tdn","hidden")}><strong>car</strong></td> <td class={if(ptm_3=="Y","tdf","hidden")}> </td> <td class={if(ptm_3=="Y","tdn","hidden")}><strong>bike</strong></td> <td class={if(ptm_2=="Y","tdf","hidden")}> </td> <td class={if(ptm_2=="Y","tdn","hidden")}><strong>ebike</strong></td> </tr> </thead> <tbody> <tr style="height: 3px; text-align: center;"> </tr> <tr> <td class="td1">riding time</td> <td class={if(ptm_1=="Y","tdf","hidden")}> </td> <td class={if(ptm_1=="Y","tdn","hidden")}>Option 1</td> <td class={if(ptm_3=="Y","tdf","hidden")}> </td> <td class={if(ptm_3=="Y","tdn","hidden")}>Option 2</td> <td class={if(ptm_2=="Y","tdf","hidden")}> </td> <td class={if(ptm_2=="Y","tdn","hidden")}>Option 3</td> </tr> <tr style="height: 3px; text-align: center;"> </tr> <tr> <td class="td1">cost</td> <td class={if(ptm_1=="Y","tdf","hidden")}> </td> <td class={if(ptm_1=="Y","tdn","hidden")}>Option 1</td> <td class={if(ptm_3=="Y","tdf","hidden")}> </td> <td class={if(ptm_3=="Y","tdn","hidden")}>Option 2</td> <td class={if(ptm_2=="Y","tdf","hidden")}> </td> <td class={if(ptm_2=="Y","tdn","hidden")}>Option 3</td> </tr> <tr style="height: 3px; text-align: center;"> </tr> <tr> <td class="td1"><strong>Which option would you prefer?</strong></td> <td class={if(ptm_1=="Y","tdf","hidden")}> </td> <td class={if(ptm_1=="Y","tdn","hidden")}> </td> <td class={if(ptm_3=="Y","tdf","hidden")}> </td> <td class={if(ptm_3=="Y","tdn","hidden")}> </td> <td class={if(ptm_2=="Y","tdf","hidden")}> </td> <td class={if(ptm_2=="Y","tdn","hidden")}> </td> </tr> </tbody> </table> <script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Move the radios {if(ptm_1=="Y","$('.question-text table:eq(0) tr:last td:eq(2)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(0) *', thisQuestion));","")} {if(ptm_3=="Y","$('.question-text table:eq(0) tr:last td:eq(4)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion));","")} {if(ptm_2=="Y","$('.question-text table:eq(0) tr:last td:eq(6)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(2) *', thisQuestion));","")} // Some classes for presentation $('.question-text table:eq(0) input:radio', thisQuestion).closest('td').addClass('answer-item radio-item text-center radio'); $('.question-text table:eq(0) .radio-item label', thisQuestion).show(); // Click event on the table cells $('.question-text table:eq(0) .radio-item', thisQuestion).on('click', function(e) { $('input:radio', this).trigger('click'); }); $('.question-text table:eq(0) input:radio', thisQuestion).on('click', function(e) { e.stopPropagation(); }); // Clean-up styles $('.answer-container', thisQuestion).hide(); $('.question-text table:eq(0) .label-text', thisQuestion).remove(); $('.question-text table:eq(0) .radio-text', thisQuestion).css({ 'cursor': 'pointer' }); }); </script> <style type="text/css"> thead td.tdn { background-color:#D4D7E4; text-align:center; font-size:11pt; padding-top:1em; padding-bottom:1em; vertical-align:middle; } tbody td.tdn { background-color:#f2f2f2; text-align:center; font-size:11pt; vertical-align:middle; } tbody td.tdf { width: 0px; } </style>
Here the script as *.txt file
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
- Posts: 45
- Thank you received: 0
Thanks for your patience. Because the problem of my version of limesurvey, the code of "<td class={if(ptm_1=="Y","tdf","hidden")}> </td>" would change to "<td class={if(ptm_1=="Y","tdf","hidden")}"> </td>". I am so ashamed for wasting you so much time on my problem. thank you again. I will try my best to solve this question. you really give me big help. thank you very much.
Best,
Qiang
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
- Posts: 45
- Thank you received: 0
it works!!! the command I use is shown as first figure, but from question summary, you could not see the if-statement. this condition is weird. but anyway, it works, when i choose car or bike, the alternative in the table could change in terms of my choice.
Thanks for your help. It is hard for me to describe my grateful for you. Thanks again!!!
Best,
Qiang
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12785
- Thank you received: 3940
I already asked why you did not use the work of your (former) fellow student (user name here: Xueting)?
I already proposed a quite better display of the trips like
And instead of the time picker use a input mask. More convenient for respondents.
Especially because of your 0-5 subtrips this dynamic display of lines seems to be the best way to display it.
So you can save a lot of space and make it more pleasant for the respondent.
You shouldn't use an array(5-point) if you have to explain the scale.
Use an array
And still there is no option (j1purpose) to go to a train station for national travalling.
only To get to airport or train station for international traveling
A bit strange.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
- Posts: 45
- Thank you received: 0
Actually, my questionnaire starts from "personnel or household information". the part before that is just a reference and no sense in my survey. The table I want to design is shown as the picture in attachment. the alternatives of transport modes could change in terms of the previous answers. I hope to inset some small icon in the table and keep aligning for the green part and blue part. Do you think if it is possible for the table design in limesurvey.
Best,
Qiang
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12785
- Thank you received: 3940
What are these circles?
Are these radio buttons?
And the table below. What will be inserted there?
Some fixed text or text from previous answers or input fields?
As this is a normal HTML table I do not see anything why it shouldn't work.
BUT: What do you want to ask here?
What are the respondents to answer?
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
- Posts: 45
- Thank you received: 0
I have designed a table, as shown in the picture in attachment, but it has several problems I don't know how to deal with. I want to show the red box to respondent firstly and only when respondent choose a mode in the red box, the rest part would appear. So, the first question is how i could do this except setting if-statement in each cell generation. I tried to use <div> to make the rest part as a block, but it doesn't work.
When the whole picture is shown, respondent could re-select a mode in the bottom of the picture and the option description is based on the choice in the red box and I have give a example using If-Statement in the list of Answer Option. the problem of re-selecting is that everytime i select a option in the red box, it will show the corresponding option description, but actually, I want it hide, as shown in picture.
and the last question, as you see, the buttons are not in the center of a cell, although i use the script that you told Shangqi before, as shown below, but it doesn't work.
<style type="text/css">.dir-ltr .radio-item .ls-label-xs-visibility, .dir-ltr .checkbox-item .ls-label-xs-visibility {
left: auto;
margin-left: 0px;
}
</style>
Thanks for your help.
Best wishes,
Qiang
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12785
- Thank you received: 3940
1. this question is quite different from your initial question of this thread.
You dhould have opened a new thread.
Unfortunately this happens many times and therefore we read quite often "I searched the forum but I did not find". Not very surprising with such misleading topics.
2.
Did you consider to use two questions merged with classes ".no-bottom" and ".no-question".I have designed a table, as shown in the picture in attachment, but it has several problems I don't know how to deal with. I want to show the red box to respondent firstly and only when respondent choose a mode in the red box, the rest part would appear. So, the first question is how i could do this except setting if-statement in each cell generation. I tried to use <div> to make the rest part as a block, but it doesn't work.
You'll find them somewhere in the forum.
3.
When the whole picture is shown, respondent could re-select a mode in the bottom of the picture and the option description is based on the choice in the red box and I have give a example using If-Statement in the list of Answer Option. the problem of re-selecting is that everytime i select a option in the red box, it will show the corresponding option description, but actually, I want it hide, as shown in picture.
I do not understand.
and the option description is based on the choice in the red box
everytime i select a option in the red box, it will show the corresponding option description
So what do you want?
Is the description shown or not?
And to be honest, I do not understand the image without box.
"Ride-hailing" is selected.
Now the question is "Do you want to re-select...?" with answer options "No" and "keep ride hailing"
Wouldn't it be better to insert the transportation mode into the question "Do you want to re-select ride-hailing?" anser options "Yes" and "No"?
and the last question, as you see, the buttons are not in the center of a cell, although i use the script that you told Shangqi before, as shown below, but it doesn't work.
Unfortunately I cannot check anything.
Never provide lsq nor lsg exports, only lss.
Joffm
But one general word:
Split the question. Simplify it.
Your respondents will be grateful.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.