I'm attempting to place the values of checked checkboxes into an array so I will be able to use these values to build a custom SQL statement to be run against a database.
Think of it as a Select Query Builder for non-tech people.
I can't seem to place these values into an array though. Any tips would be welcome.
Sample HTML:
<input type="checkbox" value="cat">Cat<br>
<input type="checkbox" value="dog">Dog<br>
<input type="checkbox" value="turtle">Turtle<br>
<input type="text" id="demo" hidden>
<input id="button" type="submit" value="Submit">
Sample JQuery:
$(document).ready(function(){
$("#button").click(function(){
var i;
var x = $(":checkbox:checked").toArray()
for (i = 0; I < x.length; i++) {
$("#demo").append(x.[i] + ", ");
}
});
});