How to access the keys in array of items in Sortable-Input

Hello everyone, I’m having a hard time trying to figure how to resolve this.

I would like to know how can I access and use the keys in the items array, for use in a batchInsert?

Given the next scenario: I have a tableA like this

id | tableB_id | tableC_id

Where id_tableA is auto incremental, and both tableB_id and tableC_id are FK.

I need to insert in tableA multiple id from tableB which where selected from a connected Sortable, and the same id from tableC, wich was selected from a dropdown, resulting in something like this:

id | tableB_id | tableC_id


1  |     2     |    4

2  |     3     |    4

3  |     5     |    4

.  |     .     |    4

n  |     x     |    4

There’s no problem when I select only 1 item and submit the form, but when I select two or more I can’t submit because obviously the tableB_id can accept only integer.

I changed to type text the dosis_id variable to override the "must be an integer" at the time of dragging elements to the left list.

But I’ve not be able to access the sorted list item id’s, someone suggested me to explode the variable but as far as I know the sorted elements are stored on a JS variable?

How can I access the ids of selected items?