SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Confirm dialog

  1. #1
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    Confirm dialog

    I am wanting to use the Ok/Cancel or Yes/No prompts to make sure that a user wants to delete a record.

    I am currently using the following:
    Code:
    <script language="JavaScript">
    <!--
    
    function confirmDeletion(username) {
        var b = confirm("Are you sure you want to delete username?\nThis action is final.");
        if (b == false)
        {
          return false;
        }
        else
        {
          return true;
        }
    }
    </script>
    I am passing the username variable using PHP. My problem is coming when the user clicks Cancel instead of Ok the form is still submitted. Also, I cannot include the username in the prompt itself.

    Any help would be greatly appreciated.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Left a little something out....how the function is being called.
    Code:
    <input type="submit" value="delete" onclick="return confirm('Are you sure you want to delete <?php $username ?>?\nThis action is final.')" />
    ::: certified wild guess :::


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •