views:

39

answers:

3

I have a Html Table which consists of rows that were generated dynamically (from PHP) and each row conatins the select box and textbox with the values. Now how do i know which row has been changed (i mean Select box and textbox). Iam looking to have a list of (1,3,5,7) rows that have been changed so that i can pass them to the hidden and retrive in php

 ("#tb11").change(function(){
  //Code 

 });
+2  A: 

You can monitor object for changes. Give the input's (I'm assuming they are inputs) a class of monitor and run

$(".monitor").bind("keyup", function(event){ /* Code */ });
Josh K
A: 

try this code:

$("#tb11 input").change(function(){
      // Gets the parent row of the item that has been changed and adds a class of changed
      $(this).parent().parent().addclass('changed'); 
});

You will need to give each row a unique id number, and use the following code to handle the submission:

function submitForm() {
    $('.changed').each(function () {
        // Will loop through each row that has been changed and post a value based on the id attribute
        var rowId = $(this).attr('id');
        // post the value of your row id to php
        $.post('myurl.php?rowId='+rowId, function(data) {
            //callback method for succesfull post
        });
    }
}
Adam
Sorry, are you saying the user should do a post for each changed row? Seems unlikely they would want to do that, instead your example could just say collect the rows into an array?
Ryley
+1  A: 

That will give you the index of the row, which has been changed

(function() {
  $("table").change(function(e) {
    alert($(e.target).closest("tr").index());
  });
})();​
john_doe