I'm trying to create a comma separated list from what is checked on the form.
var $StateIDs = $(':checked');
var StateIDs = '';
for (i=0, j = $StateIDs.length; i < j; i++) {
StateIDs += $StateIDs[i].val();
if (i == j) break;
StateIDs += ',';
}
There's probably a 1-liner that can do this, or a single function.
Check the second answer here. It gives you nicely simplified code for exactly what you're doing.
map() is going to be your friend here.
StateIDs will be a comma-separated string.
Step-by-step - What is going on?
Writing blind, so I have not tested.