Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: jQuery Autocomplete

jQuery Autocomplete 6 Monate 2 Tage her #106446

  • g3guy
  • g3guys Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 14
  • Karma: 0
Hi

I've faced with the typical problem of Province > Town dependency. The additional problem is that I'm currently using an Array dual scale that is using a filter array based on the previous response.

I'm working with numerous categories so have been trying to simplify as best possible.

While my Province dropdown is neat enough, my Town dropdown is rather large (since I've had to put in all possible towns).

Searching the forum posts I landed on the autocomplete workaround here:
manual.limesurvey.org/Workarounds:_Manip...wers_for_text_inputs

I figured this may be better to use. I tried it in Array (Text) but no luck there. Is it possible to use this autocomplete on arrays?

(even though I'm working with two different variables I'm happy for them to have the same options if it will make my Town variable easier to work with).

Thanks!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106474

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6334
  • Dank erhalten: 818
  • Karma: 243
You can use autocomplete on array, just need the good id.

If you are in question text
$('#answer{SGQ}XCODE_Ycode').autocomplete(states, { if i don't make error.

You can have a look to at gitorious.org/ls-selectfilter
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: tpartner, g3guy

jQuery Autocomplete 6 Monate 1 Tag her #106479

  • g3guy
  • g3guys Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 14
  • Karma: 0
Thanks Denis for the reply. I must admit, I'm not quite sure how to incorporate your suggestion?

Current I have the following for my question text:
<script type="text/javascript" charset="utf-8">
        $(document).ready(function() {
                var qID = 32597;
                var states = "State1,State2".split(',');
                $('#question'+qID+' input.text').autocomplete({source: states});
                });
</script>Name your state:

Also, where would I use your ls-selectfilter?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106485

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4192
  • Dank erhalten: 788
  • Karma: 359
Nice work Denis. We should add that to the workarounds.
Also, where would I use your ls-selectfilter?
You would place Denis' function in template.js or in the question source. Then you would apply the function to the question by placing this in the question source:
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
		selectFilterDualScale({QID});
	});
</script>

The answer codes for both scales must be the same length and the scale-2 options are filtered by the first n characters of the answer code, where n = (answer-code-length - 2). So, if you have 4-character answer codes, the filtering will be done by the first two characters. See screenshot below.

Attached is a working sample survey. In this survey I've also added a temporary fix for a bug in 2.05 that records data for unanswered dropdowns - bugs.limesurvey.org/view.php?id=8875.

Dateianhang:

Dateiname: limesurvey_survey_8831241.lss
Dateigröße: 25 KB


Capture_2014-03-19.png
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: g3guy

jQuery Autocomplete 6 Monate 1 Tag her #106486

  • g3guy
  • g3guys Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 14
  • Karma: 0
Wow, that is a very elegant solution. I'm going to go with it on my survey and report anything picked up. This certainly does improve things substantially! :)
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106487

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4192
  • Dank erhalten: 788
  • Karma: 359
Yeah, note that when the bug is fixed you can remove this part from the script in the question source of the sample survey:

$('.array-flexible-duel-scale .dropdown-item select').each(function(i) {
	if($('option[selected="selected"]', this).length == 0) {
		$(this).prepend('<option value="">Please choose...</option>');
		$(this).val('');
	}
});
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Letzte Änderung: 6 Monate 1 Tag her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106488

  • g3guy
  • g3guys Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 14
  • Karma: 0
Yes, I did pick this part up from your example survey - thanks. Will keep an eye out on the updates.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106493

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6334
  • Dank erhalten: 818
  • Karma: 243
tpartner schrieb:
Nice work Denis. We should add that to the workarounds.
Thanks Tony,

It's one of 'future' question attribute in plugin. But here there are a problem with first system if question is hidden at start... i think i fix it somewhere but don't remind where ...
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106494

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4192
  • Dank erhalten: 788
  • Karma: 359
But here there are a problem with first system if question is hidden at start...
The only problem I can see is that the width of the cloned select is set to that of the original and if the row is hidden by filtering the original has no width.

Removing this line should do the trick:
$("#"+idNewSelectFilter).width($("#"+idSelectFilter).width());

Here's another survey with filtering applied to the array.

Dateianhang:

Dateiname: limesurvey_survey_883124_with_filtering.lss
Dateigröße: 27 KB
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

jQuery Autocomplete 6 Monate 1 Tag her #106496

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6334
  • Dank erhalten: 818
  • Karma: 243
Yes, it's that, i think i fix it differently . And without this line the 'select' update his width (set to auto), i don't like it ;).

Denis
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.198 Sekunden
Donation Image