Country list and dropdown autocomplete

More
1 year 2 months ago - 1 year 2 months ago #181715 by limesurveyfu1
Hey all,

on my search for a prebuilt "where are you from" country question solution,
I ended up planing to use the country list from surveymonkey and pasting them as answers for a dropdown question.

With the list being quite long I was expecting to find an option in the settings for the dropdown,
which enables autocompletion for the possible dropdown answer options. Sadly I only found
solutions using csv. I simply want to use the answers I already inserted.

Limesurvey has this internally e.g. for lang selection:



1. How I can make a drowdown question searchable/autocomplete (see above)?
2. Is "where are you from" not universal enough to offer this prebuilt?

Version 3.15.9+190214

Thank you very much an greetings from Berlin
FU
Attachments:
Last edit: 1 year 2 months ago by limesurveyfu1.

Please Log in to join the conversation.

LimeSurvey Partners
More
1 year 2 months ago - 1 year 2 months ago #181744 by Joffm
Hi,
if you do not like the csv, just use an array.
The about 200 countries aren't to many.
And IMO you can exclude some.

Just enter
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#question{QID} input[type="text"]').autocomplete({
minLength: 2,
source: ["Test1","Test2","Test3"]
});
});
</script>

into your question code of a question type "short text".



Best regards
Joffm


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

Please Log in to join the conversation.

More
1 year 2 months ago - 1 year 2 months ago #181788 by limesurveyfu1
Thank you very much for your quick response.

I don't want to use a "short text", a dropdown perfectly limits the range of possible answers.
I don't like a csv, nor an array, because the possible answers do already exist in the dropdown.
Why you I specify them again?
Last edit: 1 year 2 months ago by limesurveyfu1.

Please Log in to join the conversation.

More
1 year 2 months ago - 1 year 2 months ago #181793 by Joffm

Why you I specify them again?

Because there is a solution.

And you seem to have an original list. (if not you can download from several websites)
If you do not, but in the drop-down. Then export the survey as "*.txt" and open in EXCEL or OpenOffice. Here you find your drop-down entries.
And to transform this to an array is done in 5 minutes with a small macro.

Or you take this:
["Afghanistan", "Ägypten", "Albanien", "Algerien", "Andorra", "Angola", "Antigua und Barbuda", "Äquatorialguinea", "Argentinien", "Armenien", "Aserbaidschan", "Äthiopien", "Australien", "Bahamas", "Bahrain", "Bangladesch", "Barbados", "Belgien", "Belize", "Benin", "Bergkarabach", "Bhutan", "Bolivien", "Bosnien und Herzegowina", "Botswana", "Brasilien", "Brunei", "Bulgarien", "Burkina Faso", "Burundi", "Chile", "Volksrepublik China", "Cookinseln", "Costa Rica", "Dänemark", "Deutschland", "Dominica", "Dominikanische Republik", "Dschibuti", "Ecuador", "El Salvador", "Elfenbeinküste", "Eritrea", "Estland", "Fidschi", "Finnland", "Frankreich", "Gabun", "Gambia", "Georgien", "Ghana", "Grenada", "Griechenland", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Indien", "Indonesien", "Irak", "Iran", "Irland", "Island", "Israel", "Italien", "Jamaika", "Japan", "Jemen", "Jordanien", "Kambodscha", "Kamerun", "Kanada", "Kap Verde", "Kasachstan", "Katar", "Kenia", "Kirgisistan", "Kiribati", "Kolumbien", "Komoren", "Kongo, Demokratische Republik", "Kongo, Republik", "Korea, Nord", "Korea, Süd", "Kosovo", "Kuba", "Kuwait", "Laos", "Lesotho", "Lettland", "Libanon", "Liberia", "Libyen", "Liechtenstein", "Luxemburg", "Madagaskar", "Malawi", "Malaysia", "Malediven", "Mali", "Malta", "Marokko", "Marshallinseln", "Mauretanien", "Mauritius", "Mazedonien", "Mexiko", "Mikronesien", "Moldawien", "Monaco", "Mongolei", "Montenegro", "Mosambik", "Myanmar", "Namibia", "Nauru", "Nepal", "Neuseeland", "Nicaragua", "Königreich der Niederlande", "Niger", "Nigeria", "Niue", "Nordzypern", "Norwegen", "Oman", "Österreich", "Osttimor / Timor-Leste", "Pakistan", "Palästina", "Palau", "Panama", "Papua-Neuguinea", "Paraguay", "Peru", "Philippinen", "Polen", "Portugal", "Ruanda", "Rumänien", "Russland", "Salomonen", "Sambia", "Samoa", "San Marino", "São Tomé und Príncipe", "Saudi-Arabien", "Schweden", "Schweiz", "Senegal", "Serbien", "Seychellen", "Sierra Leone", "Simbabwe", "Singapur", "Slowakei", "Somalia", "Somaliland", "Spanien", "Sri Lanka", "St. Kitts und Nevis", "St. Lucia", "St. Vincent und die Grenadinen", "Südafrika", "Sudan", "Südossetien", "Südsudan", "Suriname", "Swasiland", "Syrien", "Tadschikistan", "Taiwan", "Tansania", "Thailand", "Togo", "Tonga", "Transnistrien", "Trinidad und Tobago", "Tschad", "Tschechien", "Tunesien", "Türkei", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "Ungarn", "Uruguay", "Usbekistan", "Vanuatu", "Vatikanstadt", "Venezuela", "Vereinigte Arabische Emirate", "Vereinigte Staaten", "Vereinigtes Königreich", "Vietnam", "Weißrussland", "Westsahara", "Zentralafrikanische Republik", "Zypern"]

Und es ist flexibel



Regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 1 year 2 months ago by Joffm.

Please Log in to join the conversation.

More
1 year 2 months ago #181797 by DenisChenu
You can test : gitlab.com/SondagesPro/coreAndTools/select2package

It replace dropdown in survey by select2.org/ if there are more than 15 choice
. Not really tested with 3.X

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
7 months 4 weeks ago #189421 by BusyBonsai
Dear DenisChenu

We are trying to evaluate whether we want to install the select2 plugin on our institutions limesurvey installation. Since we are running dozens of surveys from diefferent projects at the same time, we'd need to know in advance: is it possible to limit this plugin to certain surveys? Or will it automatically affect all of them?

I / we didn't manage to find this information in either the select2 or limesurvey forum, hence I would be very grateful if you could clarify!

Best
Adam

Please Log in to join the conversation.

More
7 months 4 weeks ago #189455 by DenisChenu
Not currently, can be done.
extensions.sondages.pro/about/contact.html

I think it can be a settings by question too

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 months 4 days ago #195967 by ymca

Joffm wrote:

Why you I specify them again?

Because there is a solution.

And you seem to have an original list. (if not you can download from several websites)
If you do not, but in the drop-down. Then export the survey as "*.txt" and open in EXCEL or OpenOffice. Here you find your drop-down entries.
And to transform this to an array is done in 5 minutes with a small macro.

Or you take this:
["Afghanistan", ...

Und es ist flexibel



Regards
Joffm

Is this file OK?
www.limesurvey.org/downloads/file/175-li...3166-1-alpha-2-codes
Because when I use it, Instead of:
SQ00;Afghanistan
SQ01;Saudi Arabia
...
it will save them as:
AF;Afghanistan
SA;Saudi Arabia
...
Does it matter?

Please Log in to join the conversation.

More
2 months 3 days ago #195968 by Joffm
This thread is about whether to use the select2package or the autocomplete option.

What are you going to use?

And

SQ00;Afghanistan
SQ01;Saudi Arabia
...
it will save them as:
AF;Afghanistan
SA;Saudi Arabia
...
Does it matter?

shows that you never read this
https://manual.limesurvey.org/Adding_answers_or_subquestions
especially paragraph 2.Code

And if you are going to use this list, you obviously want to use the ISO-3166 Codes.
https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes


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

Please Log in to join the conversation.

More
2 months 3 days ago #195969 by ymca

Joffm wrote: shows that you never read this
https://manual.limesurvey.org/Adding_answers_or_subquestions
especially paragraph 2.Code

Yes I did, probably missed it because was stuck with SQ, AO laws...

Joffm wrote: And if you are going to use this list, you obviously want to use the ISO-3166 Codes.
https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

So from that I guess this file is good?
www.limesurvey.org/downloads/file/175-li...3166-1-alpha-2-codes
Because I didn't find any file in the wiki site.

Also this file was not ordered by the countries names so a friend helped me sort them with Excel.
But I cannot save them as "Label sets" so thought it was because of something I did (I guess it's a bug).

Please Log in to join the conversation.

More
1 month 2 weeks ago #197213 by Vinicos
Dear Joffm,

Do you have a script like this with countries' names in other languages?
Besides that, can I use this syntaxes in version 3.17.7+190627?

Thanks

Please Log in to join the conversation.

More
1 month 2 weeks ago #197215 by Joffm

in other languages

Which ones?

Just use a search engine. Wikipedia of the desired languge will show something.
Then you have to copy this into the file.
Or you translate the names by yourself.

Second question:
Which syntax?

Did you try?

Joffm


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

Please Log in to join the conversation.

More
1 month 2 weeks ago #197223 by Vinicos
Dear Joffm,

I have tried to used the syntaxes you provided:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#question{QID} input[type="text"]').autocomplete({
minLength: 2,
source: ["Test1","Test2","Test3"]
});
});
</script>

But it's not working.

As maybe it can interest someone, I used this source (for Brazilian Portuguese):

[“Á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”, “Cidade do Vaticano”, “Colômbia”, “Congo”, “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”]

Please Log in to join the conversation.

More
1 month 2 weeks ago #197232 by Joffm
If you do not provide your lss export, and you are always a bit vague in your questions
I can't help.
You see I don't know which type of question you used:
"short text" or "array(text)"?

But it's not working.

It's like "My car doesn't start. What's the problem?"

Joffm


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

Please Log in to join the conversation.

More
1 month 2 weeks ago #197235 by Vinicos
Hi

I used this syntaxes in the question source:
<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>

And it didn't work as I expected. I mean, by starting writing, for example, "Br..." (having in mind "Brasil" - Brazil in portuguese), it didn't show up the whole word.

Is it clear now?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now