- Posts: 21
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Hide dropdonw option based on table row value
- ruytterm
- Topic Author
- Offline
- Junior Member
Less
More
3 years 3 months ago #210751
by ruytterm
Hide dropdonw option based on table row value was created by ruytterm
Hello guys!
Short version:
I created a boolean column called "ACTIVE" in limesurvey table lime_answers. Now I want to hide from the dropdown list all options that have a false value set in this new column "Active". Any help?
What i want
Name Active
Opt A 1
Opt B 0 (dont show in the dropdonw list of options)
Opt C 1
Long version (context):
I have a dropdown list with all my costumers names, and the way i'm populating it is by copying this information directly from my ERP to the lime_answers table in LimeSurvey.
As a first timer in LimeSurvey, that was the most practical way that i've found to integrate my ERP directly to LS. So, my question now is: when a costumer is deactivated I want to propagate this to LimeSurvey and make the ACTIVE column of the correspondent row false. So, in that way, this customer will no longer be available to use again.
Short version:
I created a boolean column called "ACTIVE" in limesurvey table lime_answers. Now I want to hide from the dropdown list all options that have a false value set in this new column "Active". Any help?
What i want
Name Active
Opt A 1
Opt C 1
Long version (context):
I have a dropdown list with all my costumers names, and the way i'm populating it is by copying this information directly from my ERP to the lime_answers table in LimeSurvey.
As a first timer in LimeSurvey, that was the most practical way that i've found to integrate my ERP directly to LS. So, my question now is: when a costumer is deactivated I want to propagate this to LimeSurvey and make the ACTIVE column of the correspondent row false. So, in that way, this customer will no longer be available to use again.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12923
- Thank you received: 3977
3 years 3 months ago #210753
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Hide dropdonw option based on table row value
Hi,
at first a few words to your approach.
So, when there is something changed in your ERP in my opinion the best (without the "active" column) is to
a. "DELETE from 'lime_answers' WHERE qid=xxx"
b. "INSERT INTO 'lime_answers' ...
This way there are only rhe active persons in the survey. And the codes do not change.
On the other side: How many customers are there?
Why not use an "autocomplete" option?
Either by Denis' autocomplete plugin
[url] gitlab.com/SondagesPro/QuestionSettingsType/autoComplete [/url]
(which is a bit slow if there are more than 1000 rows)
Or by inserting this into your question code:
The jquery files you find in the internet.
In case of a change in your ERP just generate a new *.csv file with the active customers.
at first a few words to your approach.
How do you "copy"? By an SQL-statement?copying this information directly from my ERP to the lime_answers table in LimeSurvey
So, when there is something changed in your ERP in my opinion the best (without the "active" column) is to
a. "DELETE from 'lime_answers' WHERE qid=xxx"
b. "INSERT INTO 'lime_answers' ...
This way there are only rhe active persons in the survey. And the codes do not change.
On the other side: How many customers are there?
Why not use an "autocomplete" option?
Either by Denis' autocomplete plugin
[url] gitlab.com/SondagesPro/QuestionSettingsType/autoComplete [/url]
(which is a bit slow if there are more than 1000 rows)
Or by inserting this into your question code:
Code:
<link href="/upload/surveys/123456/files/jquery-ui.min.css" rel="stylesheet" type="text/css" /> <script src="/upload/surveys/123456/files/jquery-ui.min.js"></script> <script src="/upload/surveys/123456/files/jquery.csv.min.js"></script> <script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { var url = "/upload/surveys/123456/files/myCustomers.csv"; var Names = new Array(); $.get(url,function(data){ fullArray = $.csv.toArrays(data); $(fullArray).each(function(i, item){ Names.push(item[0]); }); $("#question{QID} input[type=text]").autocomplete({ minLength: 2, source: Names }); }); }); </script>
The jquery files you find in the internet.
In case of a change in your ERP just generate a new *.csv file with the active customers.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ruytterm
The topic has been locked.
- ruytterm
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 0
3 years 3 months ago - 3 years 3 months ago #210767
by ruytterm
Replied by ruytterm on topic Hide dropdonw option based on table row value
Hi!
I will use my unique customer code as the limesurvey ID, this also would make it easy to keep the customer info updated.
With all of this said, I asked how to hide the dropdown option based on the ACTIVE value, but I would use it also in combination with other table fields in other cases.
So, if is there any way to do it, I would be grateful.
Well, it's not exactly a copy it's more like a sync. I thought to just insert all the customers in lime_aswers and make a job to keep the lime_answers updated with my customer db.How do you "copy"? By an SQL-statement?
I will use my unique customer code as the limesurvey ID, this also would make it easy to keep the customer info updated.
I consider doing this, but, I'm not sure if this would impact the survey answers later, as I don't exactly know all the limesurvey table relations yet.a. "DELETE from 'lime_answers' WHERE qid=xxx"
I thought of using an autocomplete, but the little I know is that is used on a text field right? I need the answer to be exactly the same as my ERP customer name, and on the dropdown, I also have the customer code from de ERP. If I use a text field and autocomplete, I'll lose those 2 things. Besides, I'll have to keep updating the csv file manually or learn another way to do it.Why not use an "autocomplete" option?
With all of this said, I asked how to hide the dropdown option based on the ACTIVE value, but I would use it also in combination with other table fields in other cases.
So, if is there any way to do it, I would be grateful.
Last edit: 3 years 3 months ago by ruytterm.
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
3 years 3 months ago - 3 years 3 months ago #210839
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Hide dropdonw option based on table row value
Removing answers directly in the table will have no impact on later responses - it should be the same as removing them in the GUI which is possible, even in activated surveys.ruytterm wrote: Hi!
I consider doing this, but, I'm not sure if this would impact the survey answers later, as I don't exactly know all the limesurvey table relations yet.a. "DELETE from 'lime_answers' WHERE qid=xxx"
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 3 months ago by tpartner.
The following user(s) said Thank You: ruytterm
The topic has been locked.
- ruytterm
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 0
3 years 2 months ago #211339
by ruytterm
Replied by ruytterm on topic Hide dropdonw option based on table row value
Thanks.
I think I'll just delete the customer then.
But, I was also thinking to filter the dropdown based on who is accessing the survey, so it shows only the customers the specific user needs to see.
So, is there a way to do this?
I think I'll just delete the customer then.
But, I was also thinking to filter the dropdown based on who is accessing the survey, so it shows only the customers the specific user needs to see.
So, is there a way to do this?
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
3 years 2 months ago #211350
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Hide dropdonw option based on table row value
There is no direct filtering or relevance for dropdown answers.
The simplest solution would be different questions for different customers. (but I have no idea how many that would be)
The simplest solution would be different questions for different customers. (but I have no idea how many that would be)
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: ruytterm
The topic has been locked.
- ruytterm
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 0
3 years 2 months ago #211418
by ruytterm
Replied by ruytterm on topic Hide dropdonw option based on table row value
I think I can set a question group for each region, containing different sets of customers, and only show those that I want, based on the participant...
Maybe this would work...
Thanks to all of you that helped me.
You guys are the best!
Maybe this would work...
Thanks to all of you that helped me.
You guys are the best!
The topic has been locked.