What's new

Closed Php/jquery checkbox datatable looping.

Status
Not open for further replies.

Heizengberg

Eternal Poster
Joined
Jul 12, 2017
Posts
597
Reaction
120
Points
312
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.

Similar threads

Back
Top