john oliver john oliver - 4 months ago 15
PHP Question

How to popup the confirm button?

I cannot figure out where to put my

onclick = "return confirm('Are you sure?')
due to lot of concatenation in my case so please help me guys. here is my code:

echo "<td><a href='" . base_url().'admin/play/delete/' .$row->id."onclick="."return confirm('Are you sure?')".'>" . "<img src='".base_url()."admin_css/images/delete.png' title='delete' "/></a>"/></a>"."<a href='".base_url().'admin/play/fav/' . $row->id . "'>" ."<img src='".base_url()."admin_css/images/star.png' title='edit'/>"."</a></td>";


Need help.

Answer

Make it simple

   <td>
       <a href="<?php echo base_url(); ?>admin/play/delete/<?php echo $row->id; ?>" onclick="return confirm('Are you sure?')">
       <img src="<?php echo base_url(); ?>admin_css/images/delete.png" title="delete"/>
       </a>
       <a href="<?php echo base_url(); ?>admin/play/fav/<?php echo $row->id; ?>">
       <img src="<?php echo base_url(); ?>admin_css/images/star.png" title="edit"/>
        </a>
   </td>