Writing mutliple fields via ajax

Writing mutliple fields via ajax

I've been using jquery for a while, and I LOVE IT!

However, I've hit a wall on this one problem and I can't figure it out.

Lets say I want to have a list of text fields - 2 items per row. Hypothetically, lets call it a shopping list app.

The user comes to a page and sees 2 text fields - the product and the cost. They can enter something in, and save it. Or, they can click on "Add another row" and a new set of text fields will pop up below so they can add another product and cost. I know how to add the rows, thats not a problem.

The problem is, lets say the user added 10 different rows and then goes to save everything... how do I process it all and funnel it to an ajax request? Do I have to somehow increment each row? I've thought that I can use a hidden form variable and have it keep track of how many rows there are... but is there an easier way?

Thanks!