Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:31:25+00:00 2026-05-23T13:31:25+00:00

this was the delete link <div class=artworkdelete> <a href=javascript:void(0); id=del_<?=$artworkDetails[‘artwork_id’] ?>_<?=$temp_cat_id; ?> onclick=deleteThisArtWork(this.id)>Delete</a> </div>

  • 0

this was the delete link

    <div  class="artworkdelete">
   <a href="javascript:void(0);" id="del_<?=$artworkDetails['artwork_id'] ?>_<?=$temp_cat_id; ?>" onclick="deleteThisArtWork(this.id)">Delete</a>
 </div>

apparently, when that link is clicked, the portal deletes the data automatically, i think it’s an ajax thing because the page doesn’t refresh. so i was ask to add a confirm pop up to ask the user to click yes or no if he wants to delete the data or not, and within the confirm box , it should mention the name of the data to be deleted like e.g

"are you sure you want to delete row_title ?"

here’s the function of the deleteThisArtWork()

       function deleteThisArtWork(artwork_id){
                        var artwork_id = artwork_id.split('_');
                        var cat_id=artwork_id[2];
                        artwork_id = artwork_id[1];
                        //$('#divStatus').html('processing request, please wait');
                        //$(".pleaseWait").dialog("open");
                        openLightBox();
                        $.ajax({
                            type: 'POST',
                            url: '<?php echo BASE_URL;?>ajax/ajax_methods_gallery.php',
                            data: 'deleteartwork=yes&artwork_id='+artwork_id+'&category_id='+cat_id,
                            success: function(msg){
                             //alert(msg);
                            msg = 'done';
                            var status=msg;
                            var deleted='';

                            if(status == 'done') {
                                 var temp_lid = 'li_'+artwork_id+'_'+cat_id+'_';
                                 //alert(counter);
                                 for(var v=1;v<counter;v++){
                                    var curid = tempIdArr[v];
                                    curid = curid.split('#');
                                    var curlid = curid[0];
                                    if(temp_lid == curlid){
                                        var del_aw_pos = curid[1];
                                        break;
                                    }
                                 }

                                 del_aw = temp_lid+'#'+del_aw_pos;
                                 var i = 1;
                                 var j =0;
                                 var op = false;
                                 var delpoint;
                                 var endpoint;
                                 var delcatid = '';
                                 var artcounter = 0;
                                 var artcounterArr = new Array();
                                 $(".sortli").each(function (){
                                    var atid = this.id.split('_');
                                    //if(atid[2]!=cat_id)return;
                                    if(this.id == del_aw){
                                        deleted = 'yes';
                                        delcatid = atid[2];
                                        $(this).remove();
                                        op = true;
                                        i=i+1;
                                        delpoint=i-1;
                                        //alert('D'+delpoint);
                                        //return;
                                    }
                                    if(atid[2]==cat_id){endpoint = i-1;artcounter=artcounter+1;}
                                    else if(j==0 && artcounter > 0){
                                        if(artcounter>0)artcounter = artcounter-1;
                                        //else artcounterArr[j] = 0;
                                        artcounterArr[j] = artcounter;
                                        j=j+1;
                                        artcounter = 0;
                                    }
                                    i = i + 1;
                                });
                                //alert(delpoint)
                                //alert(endpoint);
                                //alert(artcounterArr[0]);
                                 if(op){
                                      for(var k=delpoint; k<counter-1;k++){
                                           var orderVal1 = tempOrderArr[k];
                                           if(k<endpoint)document.getElementById('sortvalid_'+(k+1)).innerHTML = orderVal1;
                                           document.getElementById('sortvalid_'+(k+1)).id = 'sortvalid_'+(k);
                                           document.getElementById('sortdn_'+(k+1)).id = 'sortdn_'+(k);
                                           document.getElementById('sortup_'+(k+1)).id = 'sortup_'+(k);
                                           var t = tempIdArr[(k+1)].split('#');
                                           t=t[0];
                                           document.getElementById(tempIdArr[(k+1)]).id = t+'#'+k;
                                      }

                                     $(".rowHead").each(function (){
                                        var taid = this.id;
                                        var sp = this.id.split("^");
                                        var a1 = sp[1];
                                        //alert(a1);
                                        //alert(cat_id);
                                        if(parseInt(a1)>parseInt(cat_id)){
                                            var a2 = sp[2];
                                            var ta = 'lititle^'+a1+'^';
                                            //alert(ta);
                                            document.getElementById(taid).id = ta+(a2-1);
                                        }
                                     });

                                     var a2temp;
                                     var a1temp;
                                     var delcat=null;
                                     var rowHeadLast;

                                     $(".rowHead").each(function (){
                                        //var taid = this.id;
                                        rowHeadLast = this;
                                        var sp = this.id.split("^");
                                        var a1 = sp[1];
                                        var a2 = sp[2];
                                        if(a2temp == a2 && delcat==null){delcat = a2temp; delcatid=a1temp;}
                                        a2temp = a2;
                                        a1temp = a1;

                                     });
                                     var delok = false;
                                     $(".rowHead").each(function (){
                                        //var taid = this.id;
                                        //alert(deleted);
                                        var sp = this.id.split("^");
                                        var a1 = sp[1];
                                        var a2 = sp[2];
                                        if(delcat == a2 && a1==delcatid && deleted==''){delok= true;deleted='yes';$(this).remove();}

                                     });
                                     //alert(delcatid);
                                     //if(!artcounterArr[0])alert('d');
                                     if(!delok){
                                        $(".rowHead").each(function (){
                                            var sp = this.id.split("^");
                                            var cid_t = sp[1];
                                            if(!artcounterArr[0] && delcatid == cid_t)$(this).remove();
                                            //else if(artcounterArr[0]<=0)$(this).remove();
                                        });

                                     }
                                     if(deleted ==''){
                                        $(rowHeadLast).remove();
                                     }
                                 }
                                 setDivsInArray();
                                 //$(".pleaseWait").dialog("close");
                                 closeLightBox();
                             }
                             else if(status == 'DBDelete:error'){
                                 //$('#row_'+artwork_id).fadeOut(3500);
                                 $('#divStatus').fadeIn(500);
                                 $('#divStatus').html('<b>Artwork Delete Error</b>');
                                 $('#divStatus').fadeOut(4500);
                             }


                           }
                         });

       }

it’s quite long , I think I don’t need all of those stuff if the requirement is just delete the data when “Yes” was clicked from the confirm pop up box

now here’s the delete PHP function

function deleteArtWork($artwork_id,$category_id){

    $artwork_cat_lookup_del = "delete from artwork_category_lookup where artwork_id = '$artwork_id' AND category_id='$category_id'";
    if(mysql_query($artwork_cat_lookup_del)){     
        $userObj = new User();
        $allArtWorkByCat = $userObj->allArtWorkByCat($category_id);
        for($itr = 0; $itr<count($allArtWorkByCat); $itr++){
            $ordr = $itr + 1;
            $art_id = $allArtWorkByCat[$itr]['artwork_id'];
            $updateSQL = "update artwork_category_lookup set artwork_display_order='$ordr'  where artwork_id = '$art_id' AND category_id = '$category_id'";
            mysql_query($updateSQL);
        }
        $action = $userObj->userActions('Artwork id: '.$artwork_id.' is deleted', 'Gallery');
        $userObj->setActionintoDB($action);
        echo 'done';
    }
    else echo 'DBDelete:error';
    return;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:31:26+00:00Added an answer on May 23, 2026 at 1:31 pm

    I don’t think that you want to start changing that code above as that is used to pass the relevant data to the php script via ajax.

    What you need is a javascript prompt to intercept the link click and give the user an option to continue or cancel the deletion action. Is this correct?

    http://www.tizag.com/javascriptT/javascriptconfirm.php

    At the start of the “deleteThisArtWork” javascript function you need to display a prompt.

    function deleteThisArtWork(artwork_id){
        var answer = confirm("Are you sure you want to delete this record?");
        if (answer){
            //do the rest of the function as usual, i.e. delete row via ajax.
        }else{
            return false;
        }
    }
    

    That should stop the user from accidentally deleting a record without at least having to accidentally click on a confirmation popup as well!

    If you want to make the text in the confirm popup dynamic, you would need to either pass in the dynamic text as a variable to the “deleteThisArtwork” method or draw it from another element on the page using some javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My html looks like this : <li> <div> <p class=delete> <a href=#>X</a> </p> </div>
I have this code: <div class=container> <div class=row> <div class=col> <a href=1 class=delete_activity>x</a> </div>
I have these pieces of HTML: <li class=icon iconDelete><a href=/projects/delete/{id}/ title=Delete this test case.></a></li>
I've got this markup (simplified): <div class='item'> <a> one link </a> <a class='trash'><img src='trash.png'/></a>
I have this markup: <asp:Repeater ID=appsRepeater runat=server> <ItemTemplate> <li> <div class=clearfix> <a href=---some code
I am getting this error when clicking the Delete button / link in a
I am iterating div and edit,delete buttons within it... How to hide the link
I have clicked on a div. In this div is an image: <div class=grid_2
I have <a href=test.php?id=2 class=confirm_delete>Click to proceed</a> and following javascript. When I click on
i have problem use link_to_remote link_to_remote document example say link_to_remote Delete this post, :update

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.