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 7910475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:52:44+00:00 2026-06-03T12:52:44+00:00

Below is the code where it is displaying the delete message ‘ $(.imagemsg +

  • 0

Below is the code where it is displaying the delete message ‘$(".imagemsg" + counter).html(data);‘. But it is displaying the delete message after a file has been deleted in the second row only, this is incorrect, it should only be displayed in the row the file was deleted from.

For example, if the file was deleted from the 3rd row, the message should be displayed in the 3rd row, if file was deleted from 6th row, it should display delete message in 6th row and etc. But at the moment no matter which row the file is deleted from, only the second row displays the delete message.

   var counter = 0;

function stopImageUpload(success, imagefilename){

      var result = '';
      counter++;

      if (success == 1){
         result = '<span class="imagemsg'+counter+'">The file was uploaded successfully!</span><br/><br/>';      
         $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>'); 
      }
      else {
         result = '<span class="imageemsg">There was an error during file upload!</span><br/><br/>';
      }


      $(".deletefileimage").on("click", function(event) {

         var image_file_name = $(this).attr('image_file_name');

    jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)
      .done(function(data) {
        $(".imagemsg" + counter).html(data);
       });

       $(this).parent().remove();

    });

      return true;   
}

The result variable is called here in the imageupload.php:

CALLBACK:

  <script language="javascript" type="text/javascript">window.top.stopImageUpload(<?php echo $result ? 'true' : 'false'; ?>, '<?php echo $_FILES['fileImage']['name'] ?>');</script>
  • 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-06-03T12:52:45+00:00Added an answer on June 3, 2026 at 12:52 pm

    This approach is not ideal overall. A better approach would probably be to give them all the same class and then use things like parent, find, children etc. to find the appropriate elements.

    However, without massively overhauling your code, i thin this should fix it:

    var _counter = counter;
    
    $('.listImage').eq(window.lastUploadImageIndex).find(".deletefileimage").on("click", function(event) {
        var image_file_name = $(this).attr('image_file_name');
    
        jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)
            .done(function(data) {
    
            $(".imagemsg" + _counter).html(data);
        });
    
        $(this).parent().remove();
    });
    

    Basically the click handler is only attached to the appropriate button and the appropriate counter value is used.

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

Sidebar

Related Questions

Below is the code where it is displaying the delete message but it is
Why is the below code displaying the php code from msg.php? $flag = file('msg.php');
I am displaying the Data in to ListView as like below code: private class
I am displaying a web page using the below code. But the title always
I am displaying two DIV panels with the code below. The only difference between
Below code is working properly now. But if I replace 'text.txt' with ' http://google.com
I used below code: var data = from query in loadedData.Descendants(chapter) select new CountryData
I'm trying to trim an exception message with the below code: Response.Redirect(IllegalCharactersError.aspx?error=); string message
I have been trying several ways of displaying my json images but my solutions
I have used below code for displaying multiple marker in the google map and

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.