1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I do a confirm box and then return true??? Help!

Discussion in 'JavaScript' started by MikeLugar, Mar 2, 2011.

  1. #1
    I have this function here that is run with the Onclick attribute for a html button. How do I insert a confirmation box before the fuction returns true. When the user click "OK" on the confirmation box the script needs to return true. It is a delete confirmation. Thanks!

    function validate()

    alert("Please Select the Recipient(s)");
    return false;

    return true;
    MikeLugar, Mar 2, 2011 IP
  2. HungryMinds

    HungryMinds Active Member

    Likes Received:
    Best Answers:
    Trophy Points:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    var answer = confirm ("Are you sure you want to delete your message?")
    if (answer)
    	alert ("Your message has been deleted.")
    	alert ("Canceled!.")
    Code (markup):
    Last edited: Mar 2, 2011
    HungryMinds, Mar 2, 2011 IP
    Five-0 likes this.