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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:57:50+00:00 2026-05-25T02:57:50+00:00

I have some PHP code which generates a number of items, its not a

  • 0

I have some PHP code which generates a number of items, its not a list per se, but we can think of it as such.

For each item, I have PHP generate a button.

I need jquery to be able to register the clicking of any one of those buttons, and then to do code and grab values based on the line item that was clicked.

So I might have code like this (in my loop statement)

<br>There is a duel being held on turn $eventturn between $name1 of house $fname1 and $name2 of house $fname2!   <input type=\"button\" id=\"sendsomeone\" value=\"Send a family member to spectate\"/>"

and jquery code like this

$('#sendsomeone').click(function() {
   alert("button was clicked.");
});

As I’m sure you can guess, this only really works for one item, not multiple items.

How I can have jquery register different button clicks, and grab data for them?

  • 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-25T02:57:50+00:00Added an answer on May 25, 2026 at 2:57 am

    $('input:button').click(function() {...}); will put the same click handler on all the buttons at once.

    The click handler can then grab text stored in some attribute of the button; you can change this attribute’s value for each button without affecting the HTML render. For instance:

    <button blah="whatsit">Click me</button>
    <button blah="ooga">Click me too</button>
    

    And this script:

    $('input:button').click(function() { alert( $(this).attr("blah") ) });
    

    Will pop up “whatsit” when the first button is clicked and “ooga” when the second is clicked.

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

Sidebar

Related Questions

I have some php files in a server which generate xml code in them.
I have some PHP code which allows me to sort a column into ascending
I have some PHP code which stores whatever is typed in a textbox in
I have some code I've written in PHP for consuming our simple webservice, which
I have some PHP code that generates dynamic tables of data on the fly.
I have some PHP code that generates a calendar and then outputs html to
I have some php code that generates a random password. Next to a text
I have a PHP generated form which consists of a list of items, each
I have some PHP code that is designed to make a spreadsheet with formulas
So I have some PHP code that looks like: $message = 'Here is the

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.