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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:27:59+00:00 2026-06-15T09:27:59+00:00

guys i have a ajax that creates a dynamic buttons, each button has a

  • 0

guys i have a ajax that creates a dynamic buttons, each button has a counter on their id. im trying to select each button and add a class to them.

   var html;
                $.ajax({
                          type:'POST',
                          url:'add_subject.php',
                     dataType:'json',
                         data:{'func_numbr':'6'},
                      success:function (data){
                           var counter_sub = 0 ;
                         $.each(data, function(i, item) {
                          if(data[i].subjct_statu == "0"){
                            $('#inactivate['+counter_sub+']').addClass("inactiveButton");
                           }
                          html = "<tr>";

                          html += "<td><lable>Subject: </label><input type='text' name='subject["+counter_sub+"]' rel='"+data[i].subj_id+"' value='"+data[i].subj_name+"'></td>";
                          html += "<td><input type='button' id='activate["+counter_sub+"]' name='active' class='button active  ' value='Apply'  > ";
                          html += "<input type='button' id='inactivate["+counter_sub+"]' name='active' class='button inactive' value='Remove from list'></td>";
                          html += "</tr>";
                 $('#curr-4thhigh-tble').append(html);

                 counter_sub = counter_sub +1;
                });
                      }     
               });

but wat im doing is not working i guess something is wrong. plss help tnx in advanced

  • 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-15T09:28:01+00:00Added an answer on June 15, 2026 at 9:28 am

    Try something like this, it should work:

    $.ajax({
        type: 'POST',
        url: 'add_subject.php',
        dataType: 'json',
        data: {
            'func_numbr': '6'
        },
        success: function(data) {
            var counter_sub = 0,
                classToAdd = "";
            $.each(data, function(i, item) {
                classToAdd = "";
                if (data[i].subjct_statu == "0") {
                    classToAdd = "inactiveButton";
                    //$('#inactivate[' + counter_sub + ']').addClass("inactiveButton");
                }
                html = "<tr>";
    
                html += "<td><lable>Subject: </label><input type='text' name='subject[" + counter_sub + "]' rel='" + data[i].subj_id + "' value='" + data[i].subj_name + "'></td>";
                html += "<td><input type='button' id='activate[" + counter_sub + "]' name='active' class='button active  ' value='Apply'  > ";
                html += "<input type='button' id='inactivate[" + counter_sub + "]' name='active' class='button inactive " + classToAdd + "' value='Remove from list'></td>";
                html += "</tr>";
                $('#curr-4thhigh-tble').append(html);
                counter_sub = counter_sub + 1;
            });
        }
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have a program that uses ajax to send a post to
Guys I have an activity which has a home button, when the button is
Hey guys I have an ajax jquery function that receives data from a php
Hey guys I have been trying different Javascript/AJAX jsf frameworks. I find most of
HI Guys I Have A jar File Named Column Reader. I am trying to
HI guys, I wanted to add an AJAX Event to my Homepage, but it
I have an AJAX script that post data in one of my PHP file:
I'm trying to get a tracking script working that uses AJAX via JQuery. This
I have a link that loads dynamic content into a div... there need to
I have an ajax based login form for my site and have noticed that

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.