Futuredatafromthetablewillbeshownthroughthecodebelow:
<?phpwhile($linhaAssociativa=mysqli_fetch_assoc($query)){?><tr><tdclass="cmenu2"><?php echo $linhaAssociativa["CommonName"]; ?></td>
<td><?php echo $linhaAssociativa["RealAddress"]?></td>
<td><?php echo $linhaAssociativa["BytesSent"]?></td>
<td><?php echo $linhaAssociativa["BytesReceived"]?></td>
<td><?php echo $linhaAssociativa["VirtualAddress"]?></td>
<td><?php echo $linhaAssociativa["Since"]?></td>
<td><?php echo $linhaAssociativa["Status"]?></td>
</tr>
<?php
} ?>
Where each row is a customer and has a status column (the last column of each row) with the value 0 or 1 .
I'musinga contextMenu plugin to create a Block / Unblock by clicking the first column of each line and a plugin of confirm clicking block (image 3).
WhatI'mtryingtodo:Whenyouright-clickonaline,iftheLock/strong>will1,ifyouunlock1will0.LaterI'llgettheinformationfromthetdthatwillsavethevalueofthestatus(0or1)andI'llplayitinadatabase-butthisisapparentlyeasy.WhatIcannotdo:IfIrightclickonGarretWintersthecontextMenuofthepluginwillopenandifitisclickedonblock,0willbecome1.HoweverIcannotrepeatthelogicforalltheotherlines(Wintersandallotherlinesbelow).
Thefunctioncode:
$(function(){$.contextMenu({selector:'NOMEDOSELETOR',callback:function(key,options){varm="clicked: " + key;
window.console && console.log(m) || alert(m);
},
items: {
"bloquear": {name: "Bloquear", icon: "edit"},
"desbloquear": {name: "Desbloquear", icon: "cut"},
}
});
$('.context-menu-one').on('click', function(e){
console.log('clicked', this);
})
});
E
$.confirm({
title:"Você tem certeza?",
content:"Você REALMENTE tem certeza que quer bloquear este cliente?",
confirmButton: 'Eu quero',
cancelButton: 'Não, nunca!',
confirm: function(){
$.alert('Ok... Como o senhor quiser');
}
});
Trying to make it as clear as possible - Let's say the table has 10 rows, and each row contains a column NAME and a STATUS column (by default with a value of 0). If I click on the first line with the right button and go on lock, it will change the STATUS (the class td cmenu2 ) to 1. BUT if I put the td of the second line also as class cmenu2 and I try to apply logic as I showed in photos / code, and right click on line two, go on lock, it will change the status of line one and not two! >