I need to remove one element from javascript array. The element I want to remove is the value of 'NT'. I have a HTML input
<input type="text" id="caseType" size="50"/>
We populate it with
var caseTypeJson = jQuery.parseJSON('${crFilingCaseDetailForm.caseTypes}');
I want to remove one element from the javascript array
jQuery(function () {
jQuery.each(caseTypeJson, function (index, item) {
if(("NT") == item.value){ // remove this element
caseTypeJson.splice(index,1);
}
if (item.value == '${crFilingCaseDetailForm.selectedCase.caseType}') {
jQuery('#caseType').val(item.value + ' - ' + item.description);
jQuery('#selectedCaseType').val(item.value);
}
});
});
This splice approach is not working. In doing some prior research I also tried the javascript delete too and that left the undefined element. Does this seem like a good way to do this?
Thanks,
Tom