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.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with confirm pop up window

    I have a link that I want when the user clicks on it a confirm pop-up to appear.
    But it’s not working.
    Can you please help me?


    Code:
    echo '
     </td><td width="15%" bgcolor="'.$bg_color.'" align="center" class="update"><div class="update">
    <a href="index.php?autoid='. $autoid .'" class="update" OnClick= "return confirm("do you really want to delete")">DELETE</a></div></td></tr>';

  • #2
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you gesf

    I tried this but it’s still not working
    Code:
    <script language="javascript">
    function cconfirmation(aid) {
         var x = confirm("Do you really want to delete?");
         if (x == true) {
              window.location.replace(aid);
         } else {
              return false;
         }  
    }
    </script>
    
    <td width="15%" bgcolor="<? echo $bg_color ?>" align="center" class="update"><div class="update">
    <a href="javascript:cconfirmation(/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>)" 
    class="update">DELETE</a></div></td>

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please Help

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    The argument in your 'cconfirmation' is a string and needs single quotes:
    Code:
    <td width="15%" bgcolor="<? echo $bg_color ?>" align="center" class="update"><div class="update">
    <a href="javascript:cconfirmation('/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>')" 
    class="update">DELETE</a></div></td>

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    your second attempt is on the right track but you have an error in the syntax.

    <a href="javascript:cconfirmation(/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>)"
    class="update">DELETE</a>

    should be:

    <a href="javascript:cconfirmation('/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>')"
    class="update">DELETE</a>
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #6
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Putting confirm in the onclick handler itself is better, you don't have to create a function and more importantly, the link will still work even if javascript is disabled.

    Code:
    echo '
     </td><td width="15%" bgcolor="'.$bg_color.'" align="center" class="update"><div class="update">
    <a href="index.php?autoid='. $autoid .'" class="update" OnClick= "return confirm(\'do you really want to delete\')">DELETE</a></div></td></tr>';
    I escaped the single quote because the link is inside a PHP string delimited by single quotes.


  •  

    Posting Permissions

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