• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to add onclick event in anchor button?

#1
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 ?
Reply

#2
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"'
Reply

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

onclick Event
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(10-05-2018, 04: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 .
Reply

#5
(10-05-2018, 05: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'
 
           ]
 
       );
 ?>
Reply

#6
(10-05-2018, 05:18 AM)qury Wrote:
(10-05-2018, 05: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.
Reply

#7
(10-05-2018, 06: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
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.