Welcome Guest, Not a member yet? Register   Sign In
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

(This post was last modified: 10-05-2018, 01:06 AM by Pertti.)

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, 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 .
Reply
#5

(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'
 
           ]
 
       );
 ?>
Reply
#6

(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.
Reply
#7

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB