I have an array like this containing data like : [mode:id:A:B]
eg:
["del:123456789:0:0", "del:99887766:0:0", "edit:1471872633890:8845:0"]
is there anyway I can check and see if there is a partial match on the id and the remove then entry and replace it ?
eg:
match on 1471872633890 and replace the entire entry match with edit:1471872633890:8845:NE so the array becomes :
["del:123456789:0:0", "del:99887766:0:0", "edit:1471872633890:8845:NW"]
As an aside... can you serialize an array for ajax posting ? If not I need to rethink this anyway !
Thanks
UPDATE I'm trying to update an existing array entry or add a new entry.
This is what I've got...
var id = $(this).closest('tr').find('input[name="id[]"]').val()
var A = $(this).closest('tr').find('input[name="A[]"]').val()
var B = $(this).closest('tr').find('input[name="A[]"]').val()
var res = 'edit:' + id + ':' + A + ':' + B;
filters = filters.map(function(value) {
if( value.indexOf(id) > -1 ) {
return res;
}
return value;
});
How do I actually update the values in the array ?