🔒 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
  • 688
    Views
  • 2
    Participants
Last reply from:
Impostor Syndrome

Trending Topics

Online now

Members online
636
Guests online
1,042
Total visitors
1,678

Forum statistics

Threads
2,287,419
Posts
29,044,583
Members
1,216,522
Latest member
mrshanks
Back
Top