SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  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..........
    Plz help.................

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    It doesn't look like you've loaded jQuery in that page. Have you?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post
    It doesn't look like you've loaded jQuery in that page. Have you?
    I don't understand
    what you want to say???/

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't look like you've loaded jQuery in that page. Have you?
    Here, I bolded the important words that might help you comprehend better

  5. #5
    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)
    Good point about not including jquery, although the OP might have it in the "jquery.confirm.js" script.

    ankit, you've posted your thread twice. I posted a response in your other thread but I'll copy it here so we can just do everything here.

    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.


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
  •