javascript - how to show return answer from return confirm -


how show alert result javascript return confirm()?

the script this:

<td width="25" align="center" title="delete"> <?php echo '<a href="'.base_url().'index.php/ticket_controller/confirm_hr_ticket/'.$row->id.'" onclick="return confirm(\'are sure delete '.$row->trans_code.'?\')">'?> <img style="vertical-align:middle;"src="<?php echo site_url() . 'images/btn_delete.gif'; ?>"></img></a></td> 

i want show alert('data deleted') after click yes in confirmation.

you need make function called onclick like

demo

html/php

<?php echo '<a href="'.base_url().'index.php/ticket_controller/confirm_hr_ticket/'.$row->id.'" onclick="return myfunction(\''.$row->trans_code.'\')">'?> 

javascript

function myfunction(transcode){   if(confirm('are sure delete '+ transcode + '?'))   {     //delete data     alert('data deleted');     return true;   }else{     return false;   } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -