I would like to determine the most efficient way (using jquery, or dom) to get the value of a set of checkboxes if you have one of them.
This should be generic when the input checkbox is part of a form. However, is this x-browser safe, how to do this more efficiently, and what if the checkbox is not part of a form?
function (domCheckboxElm) {
var result = $.map($(domCheckboxElm.form.elements[domCheckboxElm.name]).filter(":checked"), function(e) {
return $(e).val();
});
return result;
}
Edit:
As a side note, performance is very important here. This algorithm is needed for forms with a few input elements and for forms with thousands. And many of my users have extremely old computers ('02, '04, '05).