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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:08:38+00:00 2026-06-15T02:08:38+00:00

i made a ajax that will make a table for input and the value

  • 0

i made a ajax that will make a table for input and the value will be from php with a button of active and in active

   var counter_sub = 0 ;

     var html;
              $.ajax({
                        type:'POST',
                        url:'add_subject.php',
                   dataType:'json',
                       data:{'func_numbr':'2'},
                    success:function (data){
                       $.each(data, function(i, item) {

                        html = "<tr>";

                        html += "<td><lable>Subject: </label><input type='text' name='subject["+counter_sub+"]' value='"+data[i].subj_name+"'></td>";
                        html += "<td><input type='button' id='activate' name='active' class='button active' value='Active'> ";
                        html += "<input type='button' id='inactivate' name='active' class='button' value='Inactive'></td>";
                        html += "</tr>";
               $('#curr-elem-tble').append(html);

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

and i made a click event that will alert the value of the input beside it

$('.active').click(function (){

          var prev = $(this).parent().prev().find('input[type=text]');

            var val = $(prev).val();

          alert(val);
     });

but nothing happens when i click the active button next to it

heres the html

               <div id="curr-elem-content">
                  <table id="curr-elem-tble">

                  </table>
                </div>
  • 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-15T02:08:40+00:00Added an answer on June 15, 2026 at 2:08 am

    click() will be bind to the elements which are all present when the time of loading. and note that if you want to use click() for dynamically added elements, you have to go for live() or on() method of jQuery… so change the code to

    $('.active').live('click', function (){
    
              var prev = $(this).parent().prev().find('input[type=text]');
    
                var val = $(prev).val();
    
              alert(val);
         });
    

    See here for live

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

Sidebar

Related Questions

I make an AJAX request to a PHP script which returns a number from
I've made an application that makes full use of ajax, and what I need
I have made a simple chat application in PHP/Ajax/MySQL. I am regularly calling these
I made this bookmarklet: javascript:(function(){var s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');document.getElementsByTagName('body')[0].appendChild(s);$('#hldIntMain').hide();$('#fadeBackground').hide();return false;})() Formatted code: // Add in jQuery var
A few years ago i made am webbapp with ajax and php, i really
I am using asp.net MVC to develop an application that will have ajax interactions.
I'm finding that hitting the Refresh button on my browser will temporarily screw up
I have a PHP page that needs to make a call to a external
I am trying to make an HTML5 slideshow system that implements PHP. My idea
I've an AJAX request which will be made every 5 seconds. But the problem

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.