0

Dear Experts, I have following codes

while($res = mysqli_fetch_array($result)) {         
        echo "<tr onMouseOver=this.className='highlight' onMouseOut=this.className='normal'>";
        echo "<td align='center' width='10%' >".$res['code']."</td>";
        echo "<td align='left' width='50%' >".$res['products']."</td>";
        echo "<td align='center' width='20%'>".$res['weight']."</td>";    
        echo "<td align='center' width='20%' ><a href=\"master_u.php?id=$res[id]\"><img src=images/pencil.png alt=Edit title=Edit></a>  <a href=\"delete.php?id=$res[id]\" onClick=\"return confirm('Are you sure you want to delete?')\"><img src=images/delete16.png alt=Delete title=Delete></a></td></tr>";
    }

the codes create this result
[IMG]http://i67.tinypic.com/1zqczvd.png[/IMG]

The problem is when I press Delete icon then it ask
Are you sure you want to delete?
when I press yes then recored is deleted successfully but....
page redirects to someother page, why?

I want the page must not redirect to any other page.

Please help

2
Contributors
1
Reply
10
Views
1 Year
Discussion Span
Last Post by hericles
0

You have an href set for the <a> tag so after the onclick is processed the anchor does what it is meanrt to do. To prevent it firing change your onclick to:
onClick=\"confirm('Are you sure you want to delete?'); return false;\">

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.