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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:10:51+00:00 2026-05-31T00:10:51+00:00

I’m having an issue with php and ajax. I have built a personal workout

  • 0

I’m having an issue with php and ajax. I have built a personal workout routine website (so I can view whilst at the gym). I have built the ability to add, edit and delete routines however I am trying to build it so that the edit and delete work through ajax so that it updates on the page rather than having the need to refresh the page.

My main issue is trying to get the routine id to pass through ajax as I can’t figure out how to do it dynamically! I have manually added in the ajax that id = 15 and the top routine data changes (although need to refresh page at the moment for data to change) but as I said, can’t figure out how to dynamically pull the routine id that is been updated.

View the website here http://www.swishwebs.co.uk/workout/view_workout.php

Let me know what I need to do get that routine id.

Thanks

  • 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-31T00:10:52+00:00Added an answer on May 31, 2026 at 12:10 am

    in your anchor tag have some custom attribute lik data-id

    <a href="##" data-id="{dynamic id through looping results}" class="button>Edit</a>
    

    In jquery, you can retrieve it as

    $(this).data("id");
    

    In your code, you can have it as

    $(".button").click(function() {
            var id = $(this).data("id"); 
            var dy = $("#day").val();
            var bp = $("#body_part").val();
            var sw = $("#start_weight").val();
            var cw = $("#current_weight").val();
            var ex = $("#exercise").val();
            var st = $("#sets").val();
            var rp = $("#reps").val();
    
                //other code
    

    });

    Based on your comment, I created a sample table with two rows like below:

    <table border="0" bordercolor="#000000" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr style="border-top: 1px solid #ffffff;">
                        <Td><a href="##" data-id="5" class="button">Edit</a></td>
                        <Td>125</td>  
                    </tr>
    
    
                   <tr style="border-top: 1px solid #ffffff;">
                        <Td><a href="##" data-id="6" class="button">Edit</a></td>
                        <Td>135</td>  
                    </tr>
              </tbody>
    </table>​
    

    and jquery code for the edit link click is as below:

       $(".button").click(function(){
          var id = $(this).data("id");
          var startweight = $(this).parent().next().text();
          alert(id + ", " + startweight);
       });
    

    When the anchor tag is clicked, ‘$(this)’ refers to the element that is clicked, in your case, it in anchor tag. So when I say $(this).data(“id”), it only searches in anchor tag, but when you want to get other information from adjacent columns, you will need to learn about more DOM manipulation. I just gave an example on how to get information of adjacent columns. try for your code, and post here if you have any questions

    Once your data is updated via ajax, you can do the same. Post some sample html of where you want to update the data, then porbably we can fix it.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into

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.