views:

82

answers:

2

I need to create a grid of data many rows by 8 columns. When the user clicks on a row I need to submit the data from only that row to a php program. I'm not sure how to proceed.

Do I make each row a separate form? Do I create a hidden form and copy the row data into it, and submit that? I'm not sure how to determine which row the user clicked and how to get at that row's data.

Is there a simple way I'm over looking?

Thanks

A: 

If the cells aren't editable, I would put a form made up of hidden fields in the table, and show a submit button.

<tr>
   <td>...</td>
   <td>
      <form>
         <input type="hidden" />
         <input type="submit" />
      </form>
   </td>
</tr>

Then, with jquery, clicking the <tr> fires the submit button (bad syntax):

$('tr').click(function(){
   $(this).child('input|type=submit').click();
}
willoller
A: 

Ajax and JQuery seem like the answer here, and there are existing JQuery plugins that will do most of the heavy lifting for you.

TableEditor or Flexigrid would be good places to start with setting up click interactions, and depending on your cgi needs, the Ajax component should be pretty simple.

If you could post an example of the table you want to work with, and the sort of data you need passed to the cgi, I can edit this response with some example code.

anschauung