CodeIgniter Forums

Full Version: how to add onclick event in anchor button?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
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"'
You need to start doing your own home work I found this in like 1 second.

onclick Event
(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 .
(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'
 
           ]
 
       );
 ?>
(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.
(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