Checkboxes in table1(#tbl1) in jsp created dynamically using ajax and jquery with id like : id="123" (firstId)
$.each(json, function(idx, obj) {
$("#tbl1").append('<input type="checkbox" id='+obj.firstId+' onclick=nextPopulate('+obj.firstId+'); >'); }
In table2(#tbl2), checkboxes is created on check of checkboxes in tbl1 and whose id will be :
id="123-001" (firstId-secondId)
$.each(json, function(idx, obj) {
$("#tbl2").append('<input type="checkbox" id="'+firstId+'-'+secondId+'" >'); }
In my javascript, i'm using an ajax call to remove checkboxes in tbl2 if checkbox in tbl1 is unchecked.
The id's of second set of checkboxes will be like : "123-001" ,"123-002", "123-003", "456-001"
So,to remove all checkboxes from tbl2 whose id starts with firstId (123), if checkbox with id 123 is unchecked in tbl1.
How can i do this ?
I can use .empty(). But how to specify id as 'starts with firstId' (123)
I'm trying:
if(!($('#'+firstId).is(':checked'))){
$('#'+firstId'-').empty();