Welcome to the LimeSurvey Community Forum

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

Country list and dropdown autocomplete

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197236 by holch
Replied by holch on topic Country list and dropdown autocomplete
Ideally you always provide a LSS file with only the questions required for the problem. Then it is easier for us to understand what you are doing and checking for errors within your code. Because the problem could lie outside of this code in certain settings. I assume you prepared your survey for using Javascript, right? If not, check the manual on how to use Javascript in LS.

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.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197241 by holch
Replied by holch on topic Country list and dropdown autocomplete
In any way, I have tried the code in LimeSurvey Version 3.22.13+200415 and nothing happens when typing in the text field.

The code that I used is the code originally provided:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#question{QID} input[type="text"]').autocomplete({
minLength: 2,
source: ["Test1","Test2","Test3"]
});
});
</script>

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.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago - 4 years 1 week ago #197243 by Joffm
Replied by Joffm on topic Country list and dropdown autocomplete
This is because you have to add something to the theme.
Unfortunately it is included in one of my themes, but I still did not find, what it is.
This is the result, if you just refer to a single post, not to the original thread.
I found:
jquery-ui.min.css in the css-folder of the theme
jquery-ui.min.js in the script-folder of the theme


But nevertheless:
In the meantime we have far better solutions:
Tony's Searchable-Dropdown

github.com/tpartner/LimeSurvey-Searchable-Dropdown



Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 1 week ago by Joffm.
The following user(s) said Thank You: holch
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197287 by tpartner
Replied by tpartner on topic Country list and dropdown autocomplete
Yes, autocomplete is a jQuery UI plugin so you need to include jquery-ui.js and jquery-ui.css. You can either do it via a CDN as in the script below or include them directly as I do in my Card Sorting question theme .

But, yes, the Searchable Dropdown theme should work fine for this application.

Code for the Autocomplete plugin:

Code:
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.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() {
    $('#question{QID} input[type="text"]').autocomplete({
      minLength: 2,
      source: ["África do Sul", "Albânia", "Alemanha", "Andorra", "Angola", "Anguilla", "Antigua", "Arábia Saudita", "Argentina", "Armênia", "Aruba", "Austrália", "Áustria", "Azerbaijão", "Bahamas", "Bahrein", "Bangladesh", "Barbados", "Bélgica", "Benin", "Bermudas", "Botsuana", "Brasil", "Brunei", "Bulgária", "Burkina Fasso", "Butão", "Cabo Verde", "Camarões", "Camboja", "Canadá", "Cazaquistão", "Chade", "Chile", "China", "Vaticano", "Colômbia", "Congo", "Coreia do Norte", "Coreia do Sul", "Costa do Marfim", "Costa Rica", "Croácia", "Dinamarca", "Djibuti", "Dominica", "Estados Unidos da América", "Egito", "El Salvador", "Emirados Árabes", "Equador", "Eritreia", "Escócia", "Eslováquia", "Eslovênia", "Espanha", "Estônia", "Etiópia", "Fiji", "Filipinas", "Finlândia", "França", "Gabão", "Gâmbia", "Gana", "Geórgia", "Gibraltar", "Granada", "Grécia", "Guadalupe", "Guam", "Guatemala", "Guiana", "Guiana Francesa", "Guiné-Bissau", "Haiti", "Holanda", "Honduras", "Hong Kong", "Hungria", "Iêmen", "Ilhas Cayman", "Ilhas Cook", "Ilhas Curaçao", "Ilhas Marshall", "Ilhas Turks &amp; Caicos", "Ilhas Virgens (brit.)", "Ilhas Virgens(amer.)", "Ilhas Wallis e Futuna", "Índia", "Indonésia", "Inglaterra", "Irlanda", "Islândia", "Israel", "Itália", "Jamaica", "Japão", "Jordânia", "Kuwait", "Letônia", "Líbano", "Liechtenstein", "Lituânia", "Luxemburgo", "Macau", "Macedônia", "Madagáscar", "Malásia", "Malaui", "Mali", "Malta", "Marrocos", "Martinica", "Mauritânia", "Mauritius", "México", "Moldova", "Mônaco", "Montserrat", "Nepal", "Nicarágua", "Níger", "Nigéria", "Noruega", "Nova Caledônia", "Nova Zelândia", "Omã", "Palau", "Panamá", "Papua-Nova Guiné", "Paquistão", "Peru", "Polinésia Francesa", "Polônia", "Porto Rico", "Portugal", "Qatar", "Quênia", "República Dominicana", "República Tcheca", "Reunion", "Romênia", "Ruanda", "Rússia", "Saipan", "Samoa Americana", "Senegal", "Serra Leone", "Seychelles", "Singapura", "Síria", "Sri Lanka", "St. Kitts &amp; Nevis", "St. Lúcia", "St. Vincent", "Sudão", "Suécia", "Suíça", "Suriname", "Tailândia", "Taiwan", "Tanzânia", "Togo", "Trinidad &amp; Tobago", "Tunísia", "Turquia", "Ucrânia", "Uganda", "Uruguai", "Venezuela", "Vietnam", "Zaire", "Zâmbia", "Zimbábue"]
    });
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: holch, JamieD
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197292 by holch
Replied by holch on topic Country list and dropdown autocomplete
Thanks Tpartner! Works like a charm.

I assume that there is no chance to let "África do Sul" appear, when you type just "Af...", right? Because I tried it with that and it didn't work (obviously). So first I thought the solution doesn't work. At the end I tried "Alemanha" and it worked.

Obsivously the script requires to type the accent. Which makes sense. I just don't know if people will always write the accent, especially at the beginning. Just curious if you see any way to make this work.

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197299 by tpartner
Replied by tpartner on topic Country list and dropdown autocomplete
The plugin has no way to convert special characters so you will need to type them if you want them included in the search.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
4 years 1 week ago #197304 by Vinicos
Replied by Vinicos on topic Country list and dropdown autocomplete
Thanks, holch, tpartner and joffm,
The syntaxes worked well.
I will try to use the searchable drop-down question, but I guess I will need to e-mail my university's computer technician, as I think I can't do it myself. It seems to be a better idea to avoid missing answers.
I'm sorry sometimes my questions are not that clear, but I'm new to LS and it has been really hard to use javascript, css, jquery, and all these things. They are completely new to me.
Thanks a lot!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197305 by tpartner
Replied by tpartner on topic Country list and dropdown autocomplete

I'm sorry sometimes my questions are not that clear, but I'm new to LS and it has been really hard to use javascript, css, jquery, and all these things. They are completely new to me.

I think you're doing very well! :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197312 by holch
Replied by holch on topic Country list and dropdown autocomplete

The plugin has no way to convert special characters so you will need to type them if you want them included in the search.

I expected this already. But I thought I might ask anyway. Maybe a solution is to put the country name also without the accent, but this might confuse people and can confuse later also when it comes to analysis.

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
3 years 5 months ago #207837 by ricardo
Replied by ricardo on topic Country list and dropdown autocomplete
@Joffm. Your example does not work in Version 3.19.1+191009
The "Test!2 example in the manual does work though.

<script type="text/javascript" charset="utf-8">
alert("Test!");
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207838 by tpartner
Replied by tpartner on topic Country list and dropdown autocomplete
Did you include jQuery UI as indicated earlier in this thread?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: JamieD
The topic has been locked.
More
3 years 2 months ago #211200 by kevinleung
Replied by kevinleung on topic Country list and dropdown autocomplete
Hi tpartner, 

Thank you for sharing the script. 
May I know if "Array text" feasible to work on autocomplete function? (one of the column could autocomplete)

Kevin
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose