I have a ListView
that includes checkboxes. When the user clicks a button, it triggers an API call. This API should evaluate the state of the checkboxes and either add or remove courses based on their values. The API body should contain an array of checkbox IDs, such as [3040, 3041, 3046]
.
How can I assign unique IDs to the checkboxes and retrieve their states on the button click to include them in the API body? API body should be like:
{
"user_id": 2571,
"assignments": {
"add": {
"path_ids": 31,
"chapter_ids": [3040, 3041,3046]
},
"remove":{
"path_ids": 31,
"chapter_ids": [3042, 3213, 3245]
}
}
}