views:

41

answers:

1

I have tabled data in which most of the cells are text inputs or text areas.

Each cell is named with the row, then the column such as

<input type=text name=4_16>

where 4 is the row, underscore the divider, and 16 the column number

I have this javascript (using jquery)...

    $(document).ready(function() { 
      $('#parent').change(function() {
    $('#subcats').load('updatecell.php','value=' + $(this).val());
    return false;
});
     });

from another project. How can i modify the above to work dynamically with each cell? I will need to send the input's name (coords), and the updated value (value) to the updatecell.php. I can use name, id, or class to identify the input names if need be.

+1  A: 

You can select all text inputs in a TD and then use 'get' to send a GET request with values in the querystring like so:

$(function() {
    $('td input[type=text]').change(function() {
        var coords = $(this).attr("name").split("_");
        $.get('updatecell.php',{row: coords[0], col: coords[1], value: $(this).val()});
        return false;
    });
});
joshperry
im trying this, but it doesn't seem to be working. Using firebug and when i make a change to an input box i don't see any activity
Patrick
Try the code now, there was an erroneous space after 'input' in the selector.
joshperry