Welcome to the LimeSurvey Community Forum

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

Autocomplete a question from csv and fill two more question from same CSV

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 8 months ago - 10 years 8 months ago #97120 by tpartner
Well, I see a few possible problems.

1) This:
Code:
var qCompanyName = answer86545X17X536;
Should be
Code:
var qCompanyName = $('#answer86545X17X536');


2) This:
Code:
var qCompanyId = answer86545X17X538
Should be
Code:
var qCompanyId = $('#answer86545X17X538');


3) Does http://bozpcf/templates/default/php/companies.csv actually exist?


4) It looks like the attached CSV file has the company IDs in the first column and the names in the second but your script indicates that you want them the other way around. The autocomplete function will look at the first column and qCompanyId will be populated from the second column.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 8 months ago by tpartner.
The topic has been locked.
More
10 years 8 months ago #97139 by xsiyez
Hi Tony

Thanks for the response. I have modified the variables as suggested and swapped the column names in the csv.... :). The csv actually exists as I can browse to in the browser and can see its output in firebug console when I load the csv url.

However, the error:
Code:
TypeError: jQuery.csv is not a function
fullArray = jQuery.csv()(data);
Still appears in firebug. I see the complaint in firebug is on
Code:
jQuery.csv()
.I only included
Code:
jquery.csv.js
from here in startpage.pstpl. Do I need to include any other javascript plugin apart from the
Code:
jquery.csv.js
plugin and the javascript that I included in the question group?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 8 months ago #97140 by tpartner
Can you activate a test survey?

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
10 years 8 months ago #97147 by xsiyez
Please find attached the test survey with other relevant files attached. Kindly change the csv url in the javascript attached to question 1_0 source.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 8 months ago - 10 years 8 months ago #97160 by tpartner
Ah, I get it now.

You are using a new version of jquery.csv.js, so this:
Code:
fullArray = jQuery.csv()(data);
Needs to be changed to this:
Code:
fullArray = $.csv.toArrays(data);


Here is an updated version of your survey with the following changes:
- The script is now in the source of 1_2
- Added a snippet to automatically detect the questions and their text inputs (questions must be sequential)
- The script automatically looks for the CSV file in the template directory

Attachment limesurvey_survey_6928591.lss not found


And here is a template with your CSV file and jquery.csv.js in it.

Attachment test_csv.zip not found


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 8 months ago by tpartner.
The topic has been locked.
More
10 years 8 months ago #97167 by xsiyez
Thanks a lot Tony!
It has worked. And thanks for the other hints you included in the js file!

Alex
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose