- Posts: 45
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
filling option circle to uncertain table' cells
- qiangqi
- Topic Author
- Offline
- Senior Member
Less
More
11 months 2 weeks ago - 11 months 2 weeks ago #243387
by qiangqi
filling option circle to uncertain table' cells was created by qiangqi
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Hi everyone,
I want to make a table to let respondent to choose a option they want. But according to every respondent's basic information, the width and number of cells of the table are uncertain. So, I use the code shown as below to try to add the option circle to different cells in corresponding situation. BUT I find the variables --v1,v2-- could not be recognized. Does anyone know how could I correct it?
Best,
Qiang
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
var v1 = "{if((plicense.NAOK=='PD2' AND numberofprivatemode=='0'),'2',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='0') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='1'),'3',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='1') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='2'),'4',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='2'),'4',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='3'),'4','hidden')))))}";
var v2 = "{if((plicense.NAOK=='PD2' AND numberofprivatemode=='0'),'4',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='0') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='1'),'5',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='1') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='2'),'6',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='2'),'7',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='3'),'7','hidden')))))}";
// Move the radios
$('.question-text table:eq(0) tr:eq(7) td:eq(v1)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(0) *', thisQuestion));
$('.question-text table:eq(0) tr:eq(7) td:eq(v2)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion));
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Hi everyone,
I want to make a table to let respondent to choose a option they want. But according to every respondent's basic information, the width and number of cells of the table are uncertain. So, I use the code shown as below to try to add the option circle to different cells in corresponding situation. BUT I find the variables --v1,v2-- could not be recognized. Does anyone know how could I correct it?
Best,
Qiang
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
var v1 = "{if((plicense.NAOK=='PD2' AND numberofprivatemode=='0'),'2',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='0') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='1'),'3',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='1') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='2'),'4',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='2'),'4',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='3'),'4','hidden')))))}";
var v2 = "{if((plicense.NAOK=='PD2' AND numberofprivatemode=='0'),'4',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='0') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='1'),'5',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='1') or (rand1=='1' AND plicense.NAOK=='PD2' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='1') or (rand1=='2' AND plicense.NAOK=='PD2' AND numberofbikes=='2'),'6',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='2') or (rand1=='2' AND plicense.NAOK=='PD1' AND numberofbikes=='2'),'7',if((rand1=='1' AND plicense.NAOK=='PD1' AND numberofprivatemode=='3'),'7','hidden')))))}";
// Move the radios
$('.question-text table:eq(0) tr:eq(7) td:eq(v1)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(0) *', thisQuestion));
$('.question-text table:eq(0) tr:eq(7) td:eq(v2)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion));
Last edit: 11 months 2 weeks ago by qiangqi.
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
11 months 2 weeks ago - 11 months 2 weeks ago #243389
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic filling option circle to uncertain table' cells
Better you send the lss export.
Joffm
And please answer the questions at the beginning which you removed partially
What I'do.
Put the whole calculation into equations and in your table
$('.question-text table:eq(0) tr:eq(7) td:eq({eq1})', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion));
Joffm
And please answer the questions at the beginning which you removed partially
What I'do.
Put the whole calculation into equations and in your table
$('.question-text table:eq(0) tr:eq(7) td:eq({eq1})', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion));
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 11 months 2 weeks ago by Joffm.
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
11 months 2 weeks ago #243393
by qiangqi
Replied by qiangqi on topic filling option circle to uncertain table' cells
Hi Joffm,
Thanks for your reply. now, the .lss structure is very very complex now. I just want to let the circle shown in different cell of a row based on different situation, shown as below. for example, in situation 1, i want it could shown in the third cell of the last row and in situation 2, i want it in the fourth cell.
Best,
Qiang
Thanks for your reply. now, the .lss structure is very very complex now. I just want to let the circle shown in different cell of a row based on different situation, shown as below. for example, in situation 1, i want it could shown in the third cell of the last row and in situation 2, i want it in the fourth cell.
Best,
Qiang
Attachments:
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
11 months 2 weeks ago #243394
by qiangqi
Replied by qiangqi on topic filling option circle to uncertain table' cells
THANKS! I will try it.
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
11 months 2 weeks ago - 11 months 2 weeks ago #243395
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic filling option circle to uncertain table' cells
Well, it is not so very complex, as it seems to be still your crowdshipper thing.
What is complex is the design of your screen.
In my opinion, this overwhelms a normal participant.
For such an online survey, this should really be made clearer.
Don't squeeze everything into one question, spread it out over several questions.
What is complex is the design of your screen.
In my opinion, this overwhelms a normal participant.
For such an online survey, this should really be made clearer.
Don't squeeze everything into one question, spread it out over several questions.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 11 months 2 weeks ago by Joffm.
Please Log in to join the conversation.
- qiangqi
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
11 months 2 weeks ago #243396
by qiangqi
Replied by qiangqi on topic filling option circle to uncertain table' cells
Hi Joffm,
you are right. it surely have too much information in a screen in my questionnaire, but for my topic, I have to put them together for getting useful data. I know the final data may not be good enough. what I could do is just make it as better as possible.
Best,
Qiang
you are right. it surely have too much information in a screen in my questionnaire, but for my topic, I have to put them together for getting useful data. I know the final data may not be good enough. what I could do is just make it as better as possible.
Best,
Qiang
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
11 months 2 weeks ago #243397
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic filling option circle to uncertain table' cells
On the other side I do not see an issue inserting the IFs into the script.
I tried in a small and simple sample survey.
But as said before:
Without the lss of these relevant questions (plicense, numberofprivate, numberofbikes, rand1, etc) and the table itself I am not able to analyze this.
Joffm
I tried in a small and simple sample survey.
But as said before:
Without the lss of these relevant questions (plicense, numberofprivate, numberofbikes, rand1, etc) and the table itself I am not able to analyze this.
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
Less
More
- Posts: 45
- Thank you received: 0
11 months 2 weeks ago - 11 months 2 weeks ago #243401
by qiangqi
Replied by qiangqi on topic filling option circle to uncertain table' cells
I am trying to combine different cell and I guess it may works.
Last edit: 11 months 2 weeks ago by qiangqi.
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
11 months 2 weeks ago #243409
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic filling option circle to uncertain table' cells
Okay, some findings.
All equation have the same result, when I answer
I have a driver license, a car and a bike.
In the last row there are 32 columns - mostly not displayed.
But in my opinion they are taken into account when you insert the radios.
This is what I get when I hard code the columns 1, 5,10,15.
And this with 29,30,31,32
Please check.
If so, you have to revise the equations.
Some more general remarks:
Please, read the manual about the implemented functions, especially "countif, countifop, sumifop"
You can shorten a lot of your equations.
And revise your equations. Only two eamples.
What for is this?
tariffcar1:
{if(order=="1",'1',if(order=="2",'1',if(order=="3",'1',if(order=="4",'1',if(order=="5",'1',if(order=="6",'1',if(order=="7",'1',if(order=="8",'1',if(order=="9",'1',if(order=="10",'1',if(order=="11",'1',if(order=="12",'1',if(order=="13",'1',if(order=="14",'1',if(order=="15",'1','1')))))))))))))))}
order has values 1-16 --> so the result is always "1"
tariffhail6:
{if(order=="1",'3',if(order=="2",'3',if(order=="3",'3',if(order=="4",'3',if(order=="5",'4',if(order=="6",'4',if(order=="7",'4',if(order=="8",'4',if(order=="9",'1',if(order=="10",'1',if(order=="11",'1',if(order=="12",'1',if(order=="13",'2',if(order=="14",'2',if(order=="15",'2','2')))))))))))))))}
Shorter:
{if(order<5,3,if(order<9,4,if(order<13,1,2)))}
And please: If you want to use numbers, write it as numbers - without quotes. Quotes mean "This is a text".
So you could not write this last equation with quotes
{if(order<"5","3",if(order<"9",4,if(order<"13","1","2")))}
Because "14" is less than "5", it is compared alphabetically.
You should not use "{rand(1,2)}", but "{if(is_empty(random1),rand(1,2),random1)}
And what for do you assign this random number "random1" to another variable "rand1"?
There is really a lot to improve and to shorten.
Joffm
All equation have the same result, when I answer
I have a driver license, a car and a bike.
In the last row there are 32 columns - mostly not displayed.
But in my opinion they are taken into account when you insert the radios.
This is what I get when I hard code the columns 1, 5,10,15.
And this with 29,30,31,32
Please check.
If so, you have to revise the equations.
Some more general remarks:
Please, read the manual about the implemented functions, especially "countif, countifop, sumifop"
You can shorten a lot of your equations.
And revise your equations. Only two eamples.
What for is this?
tariffcar1:
{if(order=="1",'1',if(order=="2",'1',if(order=="3",'1',if(order=="4",'1',if(order=="5",'1',if(order=="6",'1',if(order=="7",'1',if(order=="8",'1',if(order=="9",'1',if(order=="10",'1',if(order=="11",'1',if(order=="12",'1',if(order=="13",'1',if(order=="14",'1',if(order=="15",'1','1')))))))))))))))}
order has values 1-16 --> so the result is always "1"
tariffhail6:
{if(order=="1",'3',if(order=="2",'3',if(order=="3",'3',if(order=="4",'3',if(order=="5",'4',if(order=="6",'4',if(order=="7",'4',if(order=="8",'4',if(order=="9",'1',if(order=="10",'1',if(order=="11",'1',if(order=="12",'1',if(order=="13",'2',if(order=="14",'2',if(order=="15",'2','2')))))))))))))))}
Shorter:
{if(order<5,3,if(order<9,4,if(order<13,1,2)))}
And please: If you want to use numbers, write it as numbers - without quotes. Quotes mean "This is a text".
So you could not write this last equation with quotes
{if(order<"5","3",if(order<"9",4,if(order<"13","1","2")))}
Because "14" is less than "5", it is compared alphabetically.
You should not use "{rand(1,2)}", but "{if(is_empty(random1),rand(1,2),random1)}
And what for do you assign this random number "random1" to another variable "rand1"?
There is really a lot to improve and to shorten.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
11 months 2 weeks ago #243410
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic filling option circle to uncertain table' cells
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
Less
More
- Posts: 45
- Thank you received: 0
11 months 2 weeks ago #243414
by qiangqi
Replied by qiangqi on topic filling option circle to uncertain table' cells
Hi Joffm,
Thanks for your careful inspection!!!
I use rand(1,2) for obtaining a either 1 or 2 to random1. I found if I don't assign the number of random number "random1" to "rand1", the number of "random1" will change when I click "next" every time. Thanks for your help again.
Best,
Qiang
Thanks for your careful inspection!!!
I use rand(1,2) for obtaining a either 1 or 2 to random1. I found if I don't assign the number of random number "random1" to "rand1", the number of "random1" will change when I click "next" every time. Thanks for your help again.
Best,
Qiang
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
11 months 2 weeks ago #243417
by Joffm
But this is explained here for about 1000 times.
JOffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic filling option circle to uncertain table' cells
Therefore we use this {if(is_empty(random),rand(1,2),random)}will change when I click "next" every time.
But this is explained here for about 1000 times.
JOffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.