I am trying to create a hidden input inside of a form for each row that is checked and I want to insert the value of each hidden input with the ids that are from a hidden column.
Here is what i have so far:
.on('check.bs.table check-all.bs.table', function (row) {
var selects = $('#users-table').bootstrapTable('getSelections');
ids = $.map(selects, function (row) {
return row.id;
});
var input = document.createElement("input");
input.setAttribute('type', 'hidden');
input.setAttribute('name', 'delete['+ids+']');
input.setAttribute("id", 'delete['+ids+']');
input.setAttribute('value', 'delete['+ids+']');
//append to form element that you want .
document.getElementById("deleteModalForm").appendChild(input);
})
It is creating a new hidden input for each box that is checked like I want it to, but the problem I am having is that it is joining the ids together. Here is an example of whats happening:
<input value="delete[3]" id="delete[3]" name="delete[3]" type="hidden">
<input value="delete[3,2]" id="delete[3,2]" name="delete[3,2]" type="hidden">
What i want it to do is this:
<input value="delete[3]" id="delete[3]" name="delete[3]" type="hidden">
<input value="delete[2]" id="delete[2]" name="delete[2]" type="hidden">
If it helps I am using Bootstrap Data Table
Can someone please help me with this?
EDIT: Here is a JSFiddle. As you check the box it will add a new input and you will see that each input joins the numbers. For this example I did not use type="hidden"