I'm trying to figure out how to break down the multiple selections in a dropdown and insert them into a table.
The project is for users to report observations. I have 3 tables, first is for the report details, second is for the list of items they can pick. (they can pick none, one, or many items from the list) and the third will store those items with the two keys from table 1 and 2.
So if observation_ID 1 has 2 items (A&C) then table 3 would have 2 rows. 1 | A, 1 | C.
I can't find any documentation or posts on how to break apart the selections from the dropdown an insert them into the table.
obs_id is found in the value parameter of the first dropdown,
item_id comes from the value parameter of the second dropdown.
It's extracted in a comprehension:
... for item_id in item_values
which is equivalent to
for item_id in item_values:
...
Here, I used a generator expression to generate tuples containing the obs_id and each item_id:
(obs_id, item_id) for item_id in item_values
Then used chain.from_iterable to "flatten" the list of tuples into a simple 1d list, which can be passed as values to runPrepQuery