Faulty selector?

Faulty selector?

 Hola,

   I'm trying to implement jQuery in a script and I'm stuck. The scenario is this: there is a table with two rows and two columns with the markup for a row like this:

<table><tr>

       <td><span><div><input>1st cell</input></div></span></td>

       <td><span><div><input>2nd cell</input></div></span></td>

             </tr>......


 Now, I'm trying to take the value that is entered in each first column(1st cell) and based on that, make an ajax call to a database and use the value thereof to populate the second column(2nd cell)

The code so far(with inline comments to explain my logic): 

 1 $(document).ready(= function(){

      // for each row

      2 $("table tr").each(function(){

      //  get the first <input> (1st cell) 

      3   $(this).find("input:first").keyup(function(){

     //save its value as diagnosis

      4   var diagnosis = $(this).val();

     //get the id of the next <input>(2nd cell) 

      5   var id = $(this).parent().parent().parent().next().find("input").attr( "id");

      6   id = '#' + id;

     // this is the callback function for the ajax call

      8   var myway = function(data){

     // parse data(ignore the drupal reference)

     10   var result = Drupal.parseJson(data);

     // change the value of the second <input>(2nd cell)

     11   $('#' + id).value(result.code);

     12    }

     // the ajax call

     13   var callback_path = 'try/' + diagnosis;

     14   $.post(callback_path,null,myway);

     15   return false;

     16        });

     17     });

     18 }   

Currently, the ajax callback seems to return nothing and I suspect the faulty line is line 11 where I try to use a variable in the selector. However, I'd be grateful for any help that addresses anything in the code above( even if I have to redesign for a better performance) and most importantly, how to get this piece of code to work. 

Cheers,

polarsky.

~