onClick confirmation?

Discussion in 'JavaScript' started by mokimofiki, Jun 3, 2009.

  1. #1
    I have the following code for a button and am wondering how to make it when click popup a window asking for confirmation before actually selling the item.

    its written using php/javascript but the basic idea should be the same ... thanks

    echo "<td align=\"center\"><a href=\"sellvehicle.php?vehicleid=" . $row['id'] . "\"><img src=\"img/sell.png\" onmouseover=\"this.src='img/sellMouseOver.png';\" onmouseout=\"this.src='img/sell.png';\" border=\"0\" /></a></td>
     
    mokimofiki, Jun 3, 2009 IP
  2. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Hi,
    very basic solution could be:

    echo "<td align=\"center\"><a href=\"sellvehicle.php?vehicleid=" . $row['id'] . "\" onclick=\"return confirm('Are you sure??')\"><img src=\"img/sell.png\" onmouseover=\"this.src='img/sellMouseOver.png';\" onmouseout=\"this.src='img/sell.png';\" border=\"0\" /></a></td>
     
    lp1051, Jun 3, 2009 IP
    mokimofiki likes this.
  3. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Thank you so much it works great ... I'm not very good with Javascript
     
    mokimofiki, Jun 4, 2009 IP