Hi, i'm trying to run a switch statement to query the dropdown options within a select, i'm having trouble with what seems to be the format of the Value logic in my head (maybe there's an error with the code logic also).
What should happen is the following:
- I have a Json for data source, where I have a series of entity_levels per entity_type.
- On the previous select the user selects an entity_type, and next dropdown should show all related entity_levels for that selected entity_type.
- User select entity_level
For some reason, the code I wrote is not working.
I'll add a screenshot of how i'm doing it:
My Data Source code:
{
"ITF": [
{
"entity_level": {
"level": "ITF - 1"
}
},
{
"entity_level": {
"level": "ITF - 2"
}
},
{
"entity_level": {
"level": "ITF - 3"
}
},
{
"entity_level": {
"level": "ITF - 4"
}
}
],
"IC": [
{
"entity_level": {
"level": "IC - 2"
}
}
],
"SOFIPO": [
{
"entity_level": {
"level": "SOFIPO - 1"
}
}
],
"SOFOM": [
{
"entity_level": {
"level": "SOFOM - 1"
}
}
]
}
And my switch value logic :
{{switch (entity_type_select.value) {
case "ITF":
level = item.ITF.entity_level.level;
break;
case "IC":
level = item.IC.entity_level.level;
break;
case "SOFIPO":
level = item.SOFIPO.entity_level.level;
break;
case "SOFOM":
level = item.SOFOM.entity_level.level
break;
default:
level = "None";
}
}}
What i'm trying do use here is this: JavaScript Switch Statement