> I'm trying to get the values of all checked check boxes in a certain > section of a page. Each of the check boxes has the same id, I could > just as easily make it a class or whatnot. > > I'm using something like: > var valArray = $('#' + id + ' input:checkbox').serializeArray(); > > Although I know the above isn't right, what is the proper query to do > this?
First, you should never, ever, have more than one element on the page with the same ID. That is the whole point of IDs, they are unique identifiers. Your hunch to use classes instead is a good one. Once you've changed the IDs to classes, you just use normal CSS selector syntax to find them in the DOM. For example, if you give them the class of 'test', you would select them like this: $('.test') or like this for improved performance: $('input.test') Of course if you've used that class name on other controls as well you can narrow the selection to just your checkboxes like this: $('input.test:checkbox') Mike