I'm using the plugin Bootstrap Select Picker, which allow (as the same of the normal select control) to select multiple values.
If I call: $('#items).val()
I'll an array of the values selected in the select control:
["1", "2"]
I would like to include each value in another object like:
var main = {
items: $('#items').val()
}
how can show also a structure like this:
[ { id: 1 }, {id: 2} ]
use map method and change it into object
let arr = ["1","2"];
arr = arr.map(num => ({id:parseInt(num)}));
console.log(arr);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments