Country list and dropdown autocomplete

More
2 months 3 weeks ago #197236 by holch
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.

Please Log in to join the conversation.

More
2 months 3 weeks ago #197241 by holch
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:
<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.

Please Log in to join the conversation.

More
2 months 3 weeks ago - 2 months 3 weeks ago #197243 by Joffm
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

https://github.com/tpartner/LimeSurvey-Searchable-Dropdown



Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 2 months 3 weeks ago by Joffm.
The following user(s) said Thank You: holch

Please Log in to join the conversation.

More
2 months 3 weeks ago #197287 by tpartner
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:

<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 & 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 & Nevis", "St. Lúcia", "St. Vincent", "Sudão", "Suécia", "Suíça", "Suriname", "Tailândia", "Taiwan", "Tanzânia", "Togo", "Trinidad & 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.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: holch

Please Log in to join the conversation.

More
2 months 3 weeks ago #197292 by holch
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.

Please Log in to join the conversation.

More
2 months 3 weeks ago #197299 by tpartner
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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
2 months 3 weeks ago #197304 by Vinicos
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!

Please Log in to join the conversation.

More
2 months 3 weeks ago #197305 by tpartner

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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
2 months 3 weeks ago #197312 by holch

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.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now