PHP POST/GET value of checkbox into url in this format
<input type="checkbox" value="1">
<input type="checkbox" value="2">
<input type="checkbox" value="3">
hey, guys how to convert value of checked checkbox like this
when i submit the button
example.com?value = [1,2,3]
i have to convert like [1,2,3] cause i need to store it in API JSON is that like array or what? Thanks
in your submit button handler:
ev.preventDefault();
ev.stopPropagation();
var checked = document.querySelectorAll('input[type=checkbox]:checked');
var values = [];
for(var i = 0; i < checked.length; i++) {
values.push(checked[i].value);
}
window.location = "example.com?values=["+values.join(",")+"]";