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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:17:38+00:00 2026-06-11T05:17:38+00:00

I have already figured out how to replace a button with jquery and ajax

  • 0

I have already figured out how to replace a button with jquery and ajax like this:

$("#addButton").hide();
$('.form').show();

But on another page I display multiple submit buttons that each submit different data to a database, and I don’t know how to keep track of which button is which so that when clicked only that button disappears?

The page is created dynamically based on a search result so I have a different amount of buttons each time. I tried passing a variable for the name of an element but did not know how to then use that variable in the jquery call?

If you all have any ideas about how I can go about accomplishing this, I would appreciate it.

Update:

Here is the form being created that displays the search results and a form to click a button to send a friend request.

for($i = 0; $i<$numF;$i++){
                        $row = $resultF->fetch_assoc();
                        $friendName = $row['userName'];
                        $friendID = $row['userID'];

                        print "  
                                    <p> $friendName </p>
                                    <form method = \"post\" action = \"\" onsubmit =  \" return addFriend('$userID','$user','$friendName', '$friendID')\" >
                                         <input type = \"submit\" value = \"Send friend Request\" />    
                                    </form>


                                <hr>
                        ";

                    }

Also here is the function being called:

function addFriend(userID,user,friendName, friendID)
    {
        //run ajax
        var ajaxSettings = {
            type: "GET",
            url: "friendRequest.php",
            data: "uID="+userID+"&uName="+user+"&fName="+friendName+"&fID="+friendID,
            error: function(xhr, status, error) { alert("error: " + error); } };            

            $.ajax(ajaxSettings);

        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-11T05:17:40+00:00Added an answer on June 11, 2026 at 5:17 am

    You can refer to which button was clicked using this:

    $("button").click(function() {
        $(this).hide()
    }
    

    Will hide the clicked button. Other than that, I don’t know how to help you because you didn’t supply enough information.

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

Sidebar

Related Questions

As I have already figured out. I want to create a web service on
I have already download and install this package to support HTML5 input type http://support.microsoft.com/kb/2468871
I have already googled and searched stackoverflow but I can find nothing related to
I have already read some posts, but no one helped me with my problem.
So i wanna do something like this in php. If i have a year
I already asked a question today : This one Now I have a code
I have been frustrated by this for like a day...please help. I have an
I have an order submitting form where I want to replace URL texts with
I have this piece of JS: $('.self_delete').live('click', function(e){ e.preventDefault(); $.ajax({ type: 'DELETE', url: $(this).attr('href'),
Stuff I've already figured out I'm learning how to create a multi-tenant application in

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.