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?


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>';

    onclick="return javascript:confirm('do you really want to delete');"

      I tried this but it’s still not working

      <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>

        Here is what I use in one of my script, you can modify it.

        <script type="text/javascript">
                  <!--
                  function confirmRemoval(text){
                    var confirmTXT = text;
                    var confirmBOX = confirm(confirmTXT);
                    if(confirmBOX == true){
                       //do stuff
                    }
                  }
                  //-->
                </script>
        
        onclick="confirmRemoval('text');"

          I think I see your problem ... change <script language="javascript"> to <script type="text/javascript">

            thank you kudose
            I tried what you told me to do but nothing

              <a href="index.php?autoid='. $autoid .'" class="update" OnClick= "return confirm("do you really want to delete")">DELETE</a></div></td></tr>';

              This won't work because the double quotes around the Javascript string literal are confused with the double quotes around the attribute value.

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

              This won't work either because now the Javascript string literal isn't quoted at all.

              What are you doing to debug?

                Write a Reply...