Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts

    Are you sure you want to delete? Not working

    I have a link that will delete an entry in my database table, but I would like a pop up that will ask if you "Are you sure". My code does not work, and I was wondering if someone could help me.
    My existing code that works:
    Code:
    echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' ">Delete</a></td>';
    Now my new attempt that does not work:
    Code:
    echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' " onclick="return confirm('Are you sure you want to delete?')">Delete</a></td>';
    Thank you very much in advance.

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    It will not work using href. Since you are using javascript already,


    Look for 'location javascript' on google
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • Users who have thanked BubikolRamios for this post:

    Eggweezer (02-08-2013)

  • #3
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    Thanks for getting back. I will have to look into that. Thanks again.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,633 Times in 4,595 Posts
    Quote Originally Posted by Eggweezer View Post
    Now my new attempt that does not work:
    Code:
    echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' " onclick="return confirm('Are you sure you want to delete?')">Delete</a></td>';
    I think Bubikol is totally wrong. That should work just fine.

    Bring up the page in your browser.
    Click on the browser's VIEW menu.
    Click on the SOURCE or PAGE SOURCE menu item.
    Find that line in the HTML and copy/paste the HTML here.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Eggweezer (02-09-2013)

  • #5
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    2
    Thanked 1 Time in 1 Post
    you can generate the pop up using javascript functionality..

  • Users who have thanked salesmachine for this post:

    Eggweezer (02-09-2013)

  • #6
    New Coder
    Join Date
    Sep 2012
    Location
    USA
    Posts
    13
    Thanks
    0
    Thanked 2 Times in 2 Posts
    HI ! Old Pedant you are write. it works.

  • #7
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    Hello all.
    I hate to sound ignorant, but I get an error with that line of code.
    This is the error that I get:

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/41/d383225633/htdocs/test38/admin/view_jobs.php on line 58

  • #8
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Quote Originally Posted by Old Pedant View Post
    I think Bubikol is totally wrong.
    Hmm, realy, I tested it on FF and GC and there it works, on IE8 does not work as expected, whatewer you click it goes to href.

    Anyway I don't know how java script can affect/connect to href value.
    Does not look logical to me.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • Users who have thanked BubikolRamios for this post:

    Eggweezer (02-09-2013)

  • #9
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    Thanks BubikolRamios.
    Yeah, I don't even get it to work in Chrome.
    When I upload the file and view the page, it just displays that syntax error.

  • #10
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Try this, id does not actualy delete anything, it demonstrates linking upon confirmation.

    The bottom link should work on all browsers, while upper does not work on IE 8.


    Code:
    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>
            <a href="https://www.google.si/" onclick="return confirm('Are you sure you want to delete?')">Delete href</a>
            <br />
            <a href ="#" onclick="if (confirm('Are you sure you want to delete?')) {window.location.href = 'https://www.google.si/';}">Delete javascript</a>
            
        </body>
    </html>
    Otherwise your error looks like from PHP.
    It has nothing to do with .....

    When your PHP will be error free, then you wil still have to look at html page source (and that should look something like my upper code.)

    I doubt you can look at PHP generated html source as old pedant suggested, at this stage, coz I asume it is nothin there, due to error.

    EDIT: Not PHP man myself, but if you look here: http://php.net/manual/en/language.operators.string.php

    all strings are inside "" not inside '' like in your case ..... There might be your problem.
    Last edited by BubikolRamios; 02-10-2013 at 02:34 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • Users who have thanked BubikolRamios for this post:

    Eggweezer (02-10-2013)

  • #11
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    Thanks BubikolRamios.

    Your code did work when it was the only thing on my page, BUT.... did not work when I tried to incorporate it within my code(hyperlink).I just got a syntax error.

    If you (or anyone) wouldn't mind, you can the actual domain at http://clearcreekhoney.com
    That way you could actually edit it. I know it is a hassle for you, but I am getting frustrated, and am trying to cross (understand) this hurdle.

    The ftp info is:
    Username: u65618807-CLRcreek
    Password: !clear23

    My delete does work, BUT not with the "warning" popup.
    Thank you. Sincerely, Eggweezer

  • #12
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,633 Times in 4,595 Posts
    Quote Originally Posted by Eggweezer View Post
    Hello all.
    I hate to sound ignorant, but I get an error with that line of code.
    This is the error that I get:

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/41/d383225633/htdocs/test38/admin/view_jobs.php on line 58
    That is a PHP error. It has nothing whatsoever to do with whatever browser you are using.

    PHP code happens *BEFORE* the browser ever *SEES* the code, at all.

    If you don't show the PHP code where that error is nobody can help you.

    HINT: Any error message that includes T_xxxx is a PHP error. Unless you actually had a variable or function name that started with T_ there is no standard JavaScript error that would look like that.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Eggweezer (02-11-2013)

  • #13
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    Here is my code that DOES NOT give an error, and correctly goes to the hyperlink.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
    <head> 
    </head> 
    <body>  
    <?php 
    require ('mylogin.php');
            $db = connectDB();
    
         $result = mysql_query("SELECT * FROM customers order by crm ASC")  
                    or die(mysql_error());   
                 
    ?>
         <table border='1' cellpadding='10'> 
         <tr><th>Last Name</th><th>First Name</th></tr>
    
    <?php
        $count= 0;
    	while($row = mysql_fetch_array( $result )) { 
        ++$count;
    		
    	  echo "<tr>";
    	  echo '<td width="100">' . $row['nameLast'] . '</td>';
    	  echo '<td width="100">' . $row['nameFirst'] . '</td>';
    	  echo '<td><a href="delete.php?id=' . $row['ID'] . ' ">Delete</a></td>'; 
          echo "</tr>";   
         }  
          echo "</table>";	
    ?>  
    </body> 
    </html>
    Here is my code with only the "Delete" line modified (which DOES give the PHP error).
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
    <head> 
    </head> 
    <body>  
    <?php 
    require ('mylogin.php');
            $db = connectDB();
    
         $result = mysql_query("SELECT * FROM customers order by crm ASC")  
                    or die(mysql_error());   
                 
    ?>
         <table border='1' cellpadding='10'> 
         <tr><th>Last Name</th><th>First Name</th></tr>
    
    <?php
        $count= 0;
    	while($row = mysql_fetch_array( $result )) { 
        ++$count;
    		
    	  echo "<tr>";
    	  echo '<td width="100">' . $row['nameLast'] . '</td>';
    	  echo '<td width="100">' . $row['nameFirst'] . '</td>';
    	  
    	  echo '<td><a href="delete_job.php?id=' . $row['ID'] . ' " onclick="return confirm('Are you sure you want to delete?')">Delete</a></td>'; 
    	  
          echo "</tr>";   
         }  
          echo "</table>";	
    ?>  
    </body> 
    </html>
    If anyone can figure this out, I would greatly appreciate it. Sincerely

  • #14
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    just a note, are you sure you need space there (marked with underline):

    $row['ID'] . '_" onclick
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • Users who have thanked BubikolRamios for this post:

    Eggweezer (02-12-2013)

  • #15
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    I just removed the space to no avail.

    If it helps, you can see it at www.clearcreekhoney.com

    If it is easier for you, you can download the index.php file and play with it (of course, unless it is a hassle)

    The ftp login is:
    Username:
    u65618807-CLRcreek
    Password: !clear23

    Thank you.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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