How do I extract a sub-array from a multi-dimensional array
Hello Everyone:
My goal here is to extract a sub-array from a multi-dimensional array. As users select and unselect a checkbox the array needs to be added to or subtracted from. Details follow:
- catch_array = jQuery.parseJSON($(this).val());
catch_array variable picks up value of the checkbox. The value is an array of fields in the table row, (firstName, lastName, email, userID, etc...)
Next If routine should add to the data_row array or subtract from depending on whether a user selects (or unselects) a checkbox:
- if (check == true)
- {
- data_row.push(catch_array);
- }
- else
- {
- var removeData = catch_array;
- data_row = jQuery.grep(data_row, function(value) {
- return value != removeData; });
- }
The problem is that jQuery.grep() is not working the way it does if I am just working with a simple array.
Does jQuery.grep not work with multi-dimensional arrays? And if not, how do I subtracted a sub-array from a multi-dimensional array?
Thanks In advance:
Pavilion