Welcome to the LimeSurvey Community Forum

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

auto display answer when filling open ended question

  • Tchumbura
  • Tchumbura's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #215219 by Tchumbura
hi everyone,

Right now I am doing a building a survey and in the demographic block I have a question for the teachers in which school do they teach. As numbers of the schools repeat in the different cities, and as they might missclick the button and write 33 school instead of 32, i was thinking two possible solutions that would be simpler for the respondents: 
1) give them open ended question to write their school number, and while writing the number the answer should suggest list of schools that have the same school number (e.g. city A school 32, city B school 32 etc.) just like google does.
2) another way i was thinking is asking teachers their school specific 4-digit codes. and after writing this code their school name should be displayed (e.g. after someone writes 0001, city A school 32 should be displayed to them)

Of course I have prepared excel sheets with those necessary data for either of those cases. So I would like to ask you if it's possible to do something like each of the above mentioned cases and how could it be done.

Thanks for your answers

 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago #215222 by Joffm
The easiest way is to use the "searchable drop-down"
 

"Searchable Drop-down" is a question theme you find her:
[url] github.com/tpartner/LimeSurvey-Searchable-Dropdown [/url]


Or you use the autocomplete option
E.g. here in an array(text)
 

with this javascript in the source code of the array
Code:
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js">
</script> <script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        var column = 2;
 
        $('#question{QID} .answer-item:nth-child('+(column+1)+') input[type="text"]').autocomplete({
            minLength: 2,
            source: ["0431 School 1","0432 School 2","0433 School 3","0434 School 4" ]
        });
    });
</script>

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
2 years 2 months ago - 2 years 2 months ago #224457 by Rayymetch_328054
Replied by Rayymetch_328054 on topic auto display answer when filling open ended question
Hi Joffm,

do you know a javascript workaround for the github "Searchable Drop-down" solution that you mentioned? Unfortunatly I have a university installation (version 3.17.7+190627) where it is not allowed to implement any add-ons.

Best regards
Last edit: 2 years 2 months ago by Rayymetch_328054.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago #224458 by holch
If you are on a university installation, chances are high that the XSS filter is activated and you then you can't use any Javascript either.

Have you checked if you can use Javascript code in your questions?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
2 years 2 months ago #224475 by Rayymetch_328054
Replied by Rayymetch_328054 on topic auto display answer when filling open ended question
Yes, I already did that and javascript works just fine
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago #224487 by Joffm
As it is based on the select2 package, you may download the question theme and use the select2.js and select2.css.

Sorry I can't say more.

Joffm

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