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

  • Home
  • SEARCH
  • 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 9035637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:48:16+00:00 2026-06-16T08:48:16+00:00

Basically I have a list of files composed from a foreach loop that all

  • 0

Basically I have a list of files composed from a foreach loop that all have the same code except for the name, which carries the file_id for each file. My problem is that when I added an on-click pop-up event I lose the ability to fetch the current $(".flag") attribute name. Is there a way that I can pass it along the way so I can use it in the end?

PHP: (the user sees the link which they can click…remember there are several of these as a result from the foreach loop. I’m showing one for example)

echo "<td><a href='#' class='flag' name='$files[id]' >Click Here</a>  ( $files[nums] )</td>";

jQuery: (on-click this will happen)

$(".flag").live('click', function() {
    $(".pop").show("slow"); 
    return false;
});

HTML: this div will popup

<div class="pop">
      <form method="post" id="new_folder" >
          <p><label for="folder">Reason for Reporting?</label><textarea id="report_reason" name="report_reason" maxlenght="100" style="resize:none" cols="30" rows="5">Please limit your response to 100 characters.</textarea></p>
          <p><input type="submit" value="Submit" id="message_submit"/> or <a class="close" href="/">Cancel</a></p>
      </form>
  </div>

jQuery: on submit I need to send the current $files['id'] and textarea value via ajax. The textarea sends the correct data, but the $(".flag") instead of being the id of the selected link it is the id of the first fetched id from the foreach loop

$("#message_submit").on("click", function(e){
      var fileID = $(".flag").attr("name");
      var text = $("#report_reason").val();
      $(".pop").hide("slow"); 

      $.ajax({
              url: '<?php echo base_url().'home/report_file';?>', 
              type: 'POST',
              data: { val: fileID, val2: text },
              dataType: 'json', 
              success: function(output_string){
                  $(".success").text("You have flagged this file!!").show().css({"color" : "green", "margin-top" : "10px"});
                  $(".success").fadeOut(10000);   
              }
      });
      return false;
});
  • 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-16T08:48:17+00:00Added an answer on June 16, 2026 at 8:48 am

    You can save the .flag link being clicked and later use it.

    var flagClicked;
    
    $(".flag").live('click', function() {
        $(".pop").show("slow"); 
        flagClicked = $(this);
        return false;
    });
    
    $("#message_submit").on("click", function(e){
          var fileID = flagClicked.attr("name");
           ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have basically a list of all the files in a folder, which in
Basically I have a program which, when it starts loads a list of files
I have some R code which performs some data extraction operation on all files
Basically I have a directory of DWG files stored in a List that I
So I have site list on certain pages that basically just have links to
Basically I have a draggable list which is connected with a sortable list. Works
I have a string which is basically a list of words delimited by commas.
I have written following algorithm into C# code to list down the files inside
Basically my dilemma is this. I have a list of x servers that host
Basically I have this application which scans through all mp3's in a folder 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.