Reading input values and ids

Reading input values and ids

I have a table that lists out order items.


  1. <div id="itemsummary">
        <table id="itemsummarytable">
            <tbody>
                <tr>
                <tr>
                    <td>Item 1</td>
                    <td>$6.00</td>
                    <td><input id="n_7996146" type="text"></td>
                    <td><input id="c_7996146" type="text"></td>
                </tr>
                <tr>
                    <td>Item 2</td>
                    <td>$16.00</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>Item 3</td>
                    <td>$6.00</td>
                    <td><input id="n_7979215" type="text"></td>
                    <td><input id="c_7979215" type="text"></td>
                </tr>
            </tbody>
        </table>
    </div>


























Some items have inputs, other do not.

The IDs on each input contain the ID value of the item in question. The prefix is just to keep the IDs unique.

I have tried to write some jquery to read these inputs after a button press. I almost have it but not quite. This is what I have so far



  1.            var count = 0;
                $('#itemsummary>*').each(function () {
                    $(this).find('input').each(function () {
                        if (count == 0) {
                            name = $(this).val();
                            itemid = $(this).attr('id').substring(2);
                            count = count + 1;
                        } else {
                            classs = $(this).val();
                            count = 0;
                        }
                    });
                    alert(name + ' : ' + classs + ' : ' + itemid);
                });














This only 'alerts' the bottom most set of data. (the alert is there just for testing)

Secondly, I bet there is a better way to do this than keeping a 'count' flag.

I'm reckon I should be looping through the tr's but I'm not sure how to do that.

What I need is the 2 values in the textboxes on each row, AND the itemID of the item they belong too.

Thanks.