This problem exists only in IE browser, in mozilla its working fine… i have to delete a row on click on checkbox….
Here is my code :
<table width="100%" id="seller">
<tr id="row_1" class="row">
<td><input type="checkbox" name="delete_seller" id="delete_seller" value="1" /></td>
</tr>
<tr id="row_2" class="row">
<td><input type="checkbox" name="delete_seller" id="delete_seller" value="2" /></td>
</tr>
</table>
<input type="button" id="delete" name="delete" value="Delete" onclick="delete_row('seller')"/>
var delete_ids = [];
function delete_row(tableID){
var rows = document.getElementsByClassName('row');
var delItems = document.getElementsByName('delete_seller');
for(var i=0;i < rows.length;i++){
if(delItems[i].checked == true){
delete_ids.push(rows[i].id);
jQuery(rows[i]).remove();
i = i-1;
}
}
}
Showing error on page : ‘checked’ is null or not an object.
can one please tell me the fix .
thanks in advance,
sri..
You can replace the loop with jQuery, like this:
This will select all
tr.rowelement that:hasa.deleteelement that is:checked.It calls
.remove()to remove the rows, then calls.map()to get the rows’ IDs, and applies thepushfunction to add them to your array.You can avoid the
push.applyby changing it toEDIT: Try this: