Confirm box in CodeIgniter anchor link to delete record
Everything in one line
<?=anchor("user/deleteuser/".$row->id,"Delete",array('onclick' => "return confirm('Do you want delete this record')"))?>
Try This:
<a href="javascript:void(0);" onclick="delete(<?php echo $row->id;?>);">Delete</a>
and use this in your script:
<script type="text/javascript">
var url="<?php echo base_url();?>";
function delete(id){
var r=confirm("Do you want to delete this?")
if (r==true)
window.location = url+"user/deleteuser/"+id;
else
return false;
}
</script>
Are you getting any Javascript errors in the console? I suspect that some other Javascript may be interfering. This simple test page works fine:
<?php echo anchor('user/deleteuser/'.$row->id, 'Delete', array('class'=>'delete', 'onclick'=>"return confirmDialog();")); ?>
<script>
function confirmDialog() {
return confirm("Are you sure you want to delete this record?")
}
</script>