SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to display delete warning

    PHP Code:
    <html><head><script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script src="/js/jquery.confirm.js" type="text/javascript">
    </script>
    <script language="javascript">
    // load jquery here before calling this
    $(document).ready(function() {

        // delete the entry once we have confirmed that it should be deleted
        $('#delete').click(function() {
            var parent = $(this).closest('tr');
            $.ajax({
                type: 'get',
                url: 'delete.php', // <- replace this with your url here
                data: 'ajax=1&delete=' + $(this).attr('id'),
                beforeSend: function() {
                    parent.animate({'backgroundColor':'#fb6c6c'},300);
                },
                success: function() {
                    parent.fadeOut(300,function() {
                        parent.remove();
                    });
                }
            });            
        });

        // confirm that it should be deleted
        $('#delete').confirm({
            msg:'Do you really want to delete this?',
            timeout:3000
        });        
    });
    </script></head></html>
    <?php
    require_once('upper.php');
    if(isset(
    $_COOKIE['AdminCookie'])){

    require_once(
    'database.php');
    $query="select * from events ";
    $result=mysqli_query($dbc,$query) or die('Not Connected');
    while(
    $row=mysqli_fetch_array($result)){
    echo 
    "<div id='delete'>";
    echo 
    "<a href='EventsDeleted.php?EventId=".$row['EventId']."'>".$row['Title']."</a><br><br>";
    echo 
    "<br></div>";
    }
    echo 
    "<a href='log_out.php'>Admin Log out</a><br>";
    echo 
    "<a href='AdminHome.php'>Back to Admin Home</a>";
    }

    else{echo 
    'Sorry, This page is restricted.';}
    require_once(
    'lower.php');
    In above code I want that when admin delete any event, there should an warning message prompt but my jquery not works..........
    please help.................

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can't do $('#delete').confirm(...) because confirm is nothing to do with jQuery. Also, your code doesn't seem to include any action to do if the confirmation was successful. So it was never going to work anyway - at most it would just show a message.

    This is the problem with jQuery - people learn it before learning JavaScript and then the boundaries get blurred.

    You need to just do something like this:

    Code javascript:
    if (confirm('Do you really want to delete this?')) {
      // Yes, so go ahead
    }
    else {
      // No, don't delete
    }
    Try that and if it doesn't work post what you attempted.

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,039
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


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
  •