🔒 Closed Php/jquery checkbox datatable looping.

Status
Not open for further replies.

Heizengberg

Honorary Poster
mga sir gagawa sana ako ng multiple deletion using php/js so ang logic is may magclick ka nga mga checkbox ng mga rows na gusto mi alisn then click the delete button.
so ang naisip kong way is to loop through the table at kunin yung id. but the problem is data table has an default pagination. so bali ang naloloopan lang ng code ko is yung 1stpage. eto sya

$('#sample_btn').click(function(e){
e.preventDefault();

// Declare ko muna array
var ids = [];
$(".to_array").each(function () {
if($(this).is(":checked")) {
ids.push($(this).val());
}
});

alert(ids)
});
 
Huwag loop.
It would be better kung sa checkboxes ang pag push mo ng item sa ids=[] array mo, hindi sa delete button mo.
yung maiipon dun sa ids[] mo yun ang gagamitin ng delete button mo, ganun nalang mas simple pa,
 
Huwag loop.
It would be better kung sa checkboxes ang pag push mo ng item sa ids=[] array mo, hindi sa delete button mo.
yung maiipon dun sa ids[] mo yun ang gagamitin ng delete button mo, ganun nalang mas simple pa,

bali parang ganto sir
<Script>
var ids = [];

//dito yung code ko ng checbox then add dun sa ids
<script>
 
oo parang ganyan nga.

//script
let ids = [];

//checkbox function
// all checkboxes
function pushIDToDelete(){
if(checked) ids.push(itemID)
return null;
}

//delete button function
function deleteButton(){
// ...your delete query here
}

kaw na bahala mag translate sa jquery.
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 684
    Views
  • 2
    Participants
Last reply from:
Impostor Syndrome

Online now

Members online
1,026
Guests online
738
Total visitors
1,764

Forum statistics

Threads
2,275,585
Posts
28,964,275
Members
1,231,875
Latest member
cjpeligro123
Back
Top