CodeIgniter Forums
how to add onclick event in anchor button? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: how to add onclick event in anchor button? (/thread-71884.html)



how to add onclick event in anchor button? - kvanaraj - 10-04-2018

Code:
<?php
$actionbutton1 = $row['status'] == 'Uploaded' ? anchor('Users/deleteFile/'.$row['markid'] .'/'.$row['appno'] ,' ' ,'class="fa fa-remove" onclick="return confirm('Are you sure to delete data?')" style="font-size:25px;color:red"'): anchor('Users/'.($row['markid']),' ') ;
?>
<td align="center"><?php echo $actionbutton1;?></td>  
it shows error. how to solve ?


RE: how to add onclick event in anchor button? - Pertti - 10-05-2018

You have single quotes inside a string you are trying to pass to anchor function, you need to escape these characters with \ in front of '
PHP Code:
anchor('Users/deleteFile/'.$row['markid'] .'/'.$row['appno'] ,' ' ,'class="fa fa-remove" onclick="return confirm(\'Are you sure to delete data?\')" style="font-size:25px;color:red"'



RE: how to add onclick event in anchor button? - InsiteFX - 10-05-2018

You need to start doing your own home work I found this in like 1 second.

onclick Event


RE: how to add onclick event in anchor button? - kvanaraj - 10-05-2018

(10-05-2018, 03:32 AM)InsiteFX Wrote: You need to start doing your own home work I found this in like 1 second.

onclick Event

first see my post. i am not asking in normal . my doubt is doing in anchor function .


RE: how to add onclick event in anchor button? - qury - 10-05-2018

(10-05-2018, 04:09 AM)kvanaraj Wrote: first see my post. i am not asking in normal . my doubt is doing in anchor function .

How about re-formatting your anchor like this?
PHP Code:
  <?php
        anchor
('Users/deleteFile/' $row['markid'] . '/' $row['appno'], ' ', [
 
           'class'   => 'fa fa-remove',
 
           'onclick' => "return confirm('Are you sure to delete data?')",
 
           'style'   => 'font-size:25px;color:red'
 
           ]
 
       );
 ?>



RE: how to add onclick event in anchor button? - kvanaraj - 10-05-2018

(10-05-2018, 04:18 AM)qury Wrote:
(10-05-2018, 04:09 AM)kvanaraj Wrote: first see my post. i am not asking in normal . my doubt is doing in anchor function .

How about re-formatting your anchor like this?
PHP Code:
  <?php
        anchor
('Users/deleteFile/' $row['markid'] . '/' $row['appno'], ' ', [
 
           'class'   => 'fa fa-remove',
 
           'onclick' => "return confirm('Are you sure to delete data?')",
 
           'style'   => 'font-size:25px;color:red'
 
           ]
 
       );
 ?>
Mr Pertti  already answered my post.


RE: how to add onclick event in anchor button? - Pertti - 10-05-2018

(10-05-2018, 05:51 AM)kvanaraj Wrote: Mr Pertti  already answered my post.

However, I did not know about supplying array to anchor function, so you learn something every day Smile