on change post()

on change post()

I'm reading from MySQL and populating an array to be able to edit cells.

<td> <input type="text"  name="id"  id="id[$counter]"   value="<?php echo $id;    ?>" onchange="post()"  </td>
<td> <input type="text"  name="item"  id="item[$counter]" value="<?php echo $item; ?>" onchange="post()"  </td>
 <td> <input type="text"  name="price"  id="price[$counter]" value="<?php echo $rprice;  ?>" onchange="post()"  </td>

   function post()
    {
     var id  = $("id[$counter]").val();
     var item = $("#item[$counter]").val();
     var price = $("#rprice[$counter]").val();



     $.post('update.php',   {
           postid:id,
           postitem:item,
           postrprice:rprice
            },



How can I make the var id, var itemand var price to get the value of the cel/row being modified ?