For my project i need a cascading dropdown. I used the example from here https://jsfiddle.net/mplungjan/65Q9L/
great example and it worked,... half i keep getting my data as sort af an array
[('TEST HEALTCARE',), ('TEST HEALTCARE2',), ('Test healtcare',)]
same goes for the second and third select option.
I'm using flask with jinja and the data comes from an sqlite database
any idea on how i can get a list with the values instead of the array ?
thx !!
UPDATE :
I found a way to return a JSON type list trough this snippet
var keyValueData = {{ keyValueProjects|tojson }}
//console.log(keyValueData);
var result = JSON.parse(keyValueData);
var healthcare = {};
but the result is I get a error
VM1384:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
this is my output:
var keyValueData = {"TEST ENTERPRISE": ["SubEnterprise 1"], "test Enterprise": ["subEnterprise"]}
//console.log(keyValueData);
var result = JSON.parse(keyValueData);
var healthcare = [];
From what I understand I think it has to do with the "{" at the beginning of the JSON. any idea on how i can get rid of this. Or do I miss something.
thxx!
You do not need to parse the object as it is already parsed.
simply use the
keyValueData object.
like below
var keyValueData = {{ keyValueProjects|tojson }}
var result = *keyValueData*
var healthcare = {};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.