SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    USA
    Posts
    633
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Alert

    Hi

    I am new to Javascript,please bear with me.

    What I have is a couple of check boxes about items that are to be deleted in a database ( using mysql and php).Now if a visitor to the site selects one or even more check boxes, I want an alert screen to pop up asking him if he is sure.

    If he says yes then the form is submitted,if he says no then nothing happens and the alerter dissappears.

    Please assist
    Didi

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You want to use a JavaScript confirm():

    Code:
    <script language="javascript">
    function deleteFile()
    {
        if (confirm("Are you sure?")) {
            return true;
        }
        else {
            return false;
        }    
    }
    </script>
    Code:
    <form action="processor.php" onsubmit="return deleteFile()">

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by stymiee
    You want to use a JavaScript confirm():

    Code:
    <script language="javascript">
    function deleteFile()
    {
        if (confirm("Are you sure?")) {
            return true;
        }
        else {
            return false;
        }    
    }
    </script>
    Off Topic:

    Such a verbose function!
    HTML Code:
    <script language="javascript">
    function deleteFile()
    {
        return confirm("Are you sure?");
    }
    </script>

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Off Topic:

    I mean, sure, if you want to be concise and practical your way might work.

    *stymiee slinks off back to the ecommerce forum...

  5. #5
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    USA
    Posts
    633
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

    Works 100%


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
  •