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
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 5 months ago #233958 by Joffm
Okay, if you want to forbid the reselection, this could be an easy way.

First question: Only the upper part.
After selecting a transportation mode proceed to the next question by inserting "$('#ls-button-submit').trigger('click');" here
Code:
    $('.question-text table:eq(0) .radio-item', thisQuestion).on('click', function(e) {
      $('input:radio', this).trigger('click');
      $('#ls-button-submit').trigger('click');
    });

Second question: Create the full table (upper and lower part)
Insert a mark by something like
Code:
    var v='{Q4_SQ001}';  //the selected mode
    if(v==1) {
    $('.question-text table:eq(0) tr:eq(3) td:eq(1)', thisQuestion).html('<i class="fa fa-check-circle-o fa-2x" aria-hidden="true"></i>');
    }
    if(v==2) {
    $('.question-text table:eq(0) tr:eq(3) td:eq(2)', thisQuestion).html('<i class="fa fa-check-circle-o fa-2x" aria-hidden="true"></i>');
    }
Adapt to your needs.

  

  
It's an idea, though I still think you should ease the life of the respondent.
After selecting the transportation mode in the first part only show the options of this selection in a second separate question.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • qiangqi
  • qiangqi's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 5 months ago #233964 by qiangqi
Hi Joffm,

I agree you. the screenshot you shown is I desired. I try to inset the code you provide, but I am not sure which position should be adjusted in JS and I failed to get a good result. So, could you share your lss file to me? Thanks for your help!

Best,
Qiang

Please Log in to join the conversation.

  • qiangqi
  • qiangqi's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 5 months ago #233982 by qiangqi
Hi Joffm,

I tried many times for achieving that you show, and I just get it. I use two groups and the first group include a Question which is the upper part. In second group, two Questions are included and the first is the upper part with the selected modes in first group, then, the second is the lower part. Is the operation same with yours?

Best,
Qiang

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 5 months ago #233998 by Joffm
Hi, sorry for delay. 

No, not exactly. 
I used only ONE question as second question, as it is only one question.
I merged the tables.
Now a lot of the css is not necessary, like "no-question, no-bottom", "padnot" and maybe more.

But it is still in the sample.
 

File Attachment:

File Name: limesurvey... (1).lss
File Size:56 KB


Joffm

Now you have to change the text at the bottom, or insert a further radio with the option "I like to change".
In this case you should show these two questions again. Now without the option to change again.

But do you really expect somebody to change.
Personally I would not.
I decide to drive to the supermarket by car because I want to by two crates of "Grolsch" and one of "Leffe Bruin".
Now I am polite to take a parcel with me.
Does anybody expect me to say "Oh, dan rijd ik op de bakfiets"

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • qiangqi
  • qiangqi's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 5 months ago #234010 by qiangqi
Hi Joffm,

Thanks for your help! For the extra css, if they don't have an influence, maybe i will keep them in case the possible change later.

I agree your opinion that people may not want to change a mode, which is possible. But in my design, the travelling purpose including leisure, social, and business besides shopping. Moreover, some people may not have a private mode and have to choose a public transport. I think it is possible that they will change to a mode because of a package with incentive, but i am not sure. Some people may insist, some change. That is why i do the research.

Best wishes,
Qiang

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose