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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:50:09+00:00 2026-06-17T14:50:09+00:00

I have a form in which a table of dynamic data is built with

  • 0

I have a form in which a table of dynamic data is built with PHP. Within each row is an image that when clicked calls a jQuery function with a click event.

For example, if the image has an id of eventnfo_0, i have a function like this:

$("#eventnfo_0").click(function()

It all works fine as long as I have a defined click event for each row. The problem is, I need to make it dynamic because the number of rows can vary so it’s not feasible to build a separate function as depicted above for each row.

My thought is there must be a way to call a jQuery function from an onclick event and pass a row number, but thus far, no dice.

I’m sure it’s not an uncommon task, but I’ve not had any luck with my searches.

Any thoughts are appreciated.

  • 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-17T14:50:10+00:00Added an answer on June 17, 2026 at 2:50 pm

    there are many ways tyo do this… call a same class in each img and use it as a selector…

    $('.yourClassName').click(function(){alert($(this).attr('id'));});
    

    OR

     $("[id^='eventnfo_']").click(function(){
         alert($(this).attr('id'));
     });
    

    since it is dynamically added this might help..

    $(document).on('click',"[id^='eventnfo_']".click(function(){
         alert($(this).attr('id'));
     });
    

    updated

    you can use a data attributes for a rownumber and get it from jquery..

    say this is your html.

     <img id="eventnfo_0" data-rownumber="1"/>
    

    and jquery

    $("[id^='eventnfo_']").click(function(){
         alert($(this).data('rownumber')); //this will alert 1
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple data table which contains dynamic form text fields. Each field
I have a table which contains TV Guide data. In a simplified form, the
I have a web form which has dynamic table using repeating rows. New rows
I have a form which lets you add names to the table and shows
I have a div inside of a table which is inside of a form
I am creating one form in html using table. Which have one Drop down
I have a form which POST's its data via AJAX: $.ajax({ type: POST, url:
I have this table where I can generate dynamic rows (which has input <type=text
I have a form with a row called target1 and a JavaScript which adds
I have a form in my asp.net mvc(C#) application which handles some dynamic controls.

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.