mevr
mevr

Reputation: 1125

confirm message not working

The confirm message in my href link is not working.

here is My code:

<?php 
echo '<a href="'.$delete_url.'" title="delete"  onclick="return  confirm("Are you sure you want to Remove?");">
  <img   src="'.base_url().'images/dashboard-delete-icon.png" alt="delete icon" role="presentation" width="14" height="16"/>
</a>'?> 

Please help, what mistake I'm doing.

Upvotes: 0

Views: 46

Answers (2)

Nehal
Nehal

Reputation: 1523

Check your quotes :

<?php echo '<a href="'.$delete_url.'" title="delete"  onclick="return  confirm("Are you sure you want to Remove?");">

Replace your onclick with :

onclick="return  confirm(\'Are you sure you want to Remove?\');">

Upvotes: 1

jeroen
jeroen

Reputation: 91734

Your onclick handler ends after the double quote before "Are.

<?php echo '<a href="'.$delete_url.'" title="delete"  onclick="return  confirm("Are you sure you want to Remove?");">

You should use a single quote and escape it so that you can echo it properly from php:

... onclick="return  confirm(\'Are you sure you want to Remove?\');"> ...

Upvotes: 2

Related Questions