Welcome, Guest
Username: Password: Remember me

TOPIC: Autocomplete and automatically filled questions - csv

Autocomplete and automatically filled questions - csv 2 years 10 months ago #70785

  • crescentio
  • crescentio's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Hello folks

I'm trying to design an autocomplete question, which is a numeric ID and the values come from a csv file placed in the template folder. When a value is choosen two another questions, that are hidden and in the same section, must be filled automatically. Here is an example of the csv:

123456,John,Doe
234567,Mary,Smith
3456789,Carl,Simpson

The two questions are "name" and "surname".
I'm trying to make this works with the help from this thread and his wiki post's son, but no success.
In the workarounds cited before, there is a link to the plugin but it doesn't works, so I found another source, but I'm not sure if this is the appropriate one.

I'm using the last release of LimeSurvey.
I hope that you can help me with this
Thanks in advance
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70795

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
there is a link to the plugin but it doesn't works
Are you referring to the jquery.csv.js plugin? Doesn't work how?

Do you have the autocomplete portion of this workaround working?
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.
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70798

  • crescentio
  • crescentio's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Hello Tony, thanks for answer.

Yes is the jquery.csv.js plugin. The site is in development, look.

No, the autocomplete from that workaround is not working.
Although, the automatically filled answers is more important to me than the autocomplete feature.

Thanks
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70814

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
You need to get the autocompleting function to work first - the populating of following questions depends on that.

Are there any JavaScript errors? Can you activate a sample survey for us to see?
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.
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70826

  • crescentio
  • crescentio's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Hello Tony, thanks

A sample survey is here.

The csv is equal to the example in the first post. The csv and the plugin are in templates/default folder.

The following code is in the source of the first question:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = 39255X1X1;					   
		var qName = 39255X1X2;					   
		var qSurname = 39255X1X3;
		var url = "templates/default/userdata.csv";
 
		// Create an array to hold the names
		var namesArr = new Array();
 
		// Grab the CSV contents
		$.get(url,function(data){
 
			// Convert CSV contents to an array of arrays
			fullArray = jQuery.csv()(data);
 
			// Load the names array
			$(fullArray).each(function(i, item){
				namesArr.push(item[0]);
			});
 
			// Initialise the autocomplete plugin
			$('#question'+qID+' input.text').autocomplete({
				source: namesArr,
				// Event fired when a selection is made (ui.item.value refers to the selected item)
				select: function(event, ui) { 
					// Find the "ID" and "Email" values associated with the selected name value and load those questions
					$(fullArray).each(function(i, item){
						if(item[0] == ui.item.value) {
							// The value from column 2 of the CSV
							$('#question'+qName+' input.text').val(item[1]);
							// The value from column 3 of the CSV
							$('#question'+qSurname+' input.text').val(item[2]);
						}
					}); 
				}
 
			});
		});
	});
</script>

I've attached the plugin too
jquery.csv.js
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70827

  • crescentio
  • crescentio's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Oops
Here is the plugin:
dl.dropbox.com/u/1212092/jquery.csv.js
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70832

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
The question ID vars are not correct. You don't use the full SGQA, just the question ID.

This:
var qID = 39255X1X1;					   
		var qName = 39255X1X2;					   
		var qSurname = 39255X1X3;

Should be this:
var qID = 1;					   
		var qName = 2;					   
		var qSurname = 3;
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.
Last Edit: 2 years 10 months ago by tpartner.
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70834

  • crescentio
  • crescentio's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Hi Tony, thanks

I did it in that way before and doesn't work. Anyway, I made the corrections in the sample survey and still autocomplete doesn't work.
Any other suggestion?

Thanks
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70837

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
There is no link to the plugin. You need to follow all steps in the workaround:


- Download the jquery.csv.js plugin and place it in your template folder
- Add the following line to your startpage.pstpl BEFORE the tag for template.js
<script type="text/javascript" src="{TEMPLATEURL}jquery.csv.js"></script>
Attachments:
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.
The administrator has disabled public write access.

Re: Autocomplete and automatically filled questions - csv 2 years 10 months ago #70840

  • crescentio
  • crescentio's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Thanks so much Tony

I feel so silly by forget that step :blush:
Although, when I was working in my localhost I did that step and the autocomplete doesn't work, maybe I forget another step.

Thanks so much, this was driving me crazy for days :laugh:
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.145 seconds
Donation Image