input values to array .join()

by wholypantalones

HTML

<table width="100%" border="1" cellspacing="0" cellpadding="5">
    <tr id="1">
        <td width="20%">
            <input type="checkbox" name="checkbox" id="checkbox" />
            <input type="hidden" name="part" id="part" value="12345" />
            <input type="hidden" name="lc" id="lc" value="AAA" />
        </td>
        <td>Qty:
            <input type="text" name="qty" id="qty" value="1" size="2" />
            <td width="80%">AAA 12345</td>
    </tr>
    <tr id="2">
        <td width="20%">
            <input type="checkbox" name="checkbox" id="checkbox" />
            <input type="hidden" name="part" id="part" value="54321" />
            <input type="hidden" name="lc" id="lc" value="BBB" />
        </td>
        <td>Qty:
            <input type="text" name="qty" id="qty" value="1" size="2" />
            <td width="80%">BBB 54321</td>
    </tr>
    <tr id="3">
        <td width="20%">
            <input type="checkbox" name="checkbox" id="checkbox" />
            <input type="hidden" name="part" id="part" value="999" />
            <input type="hidden" name="lc" id="lc" value="CCC" />
        </td>
        <td>Qty:
            <input type="text" name="qty" id="qty" value="1" size="2" />
            <td width="80%">CCC 999</td>
    </tr>
    <tr id="4">
        <td width="20%">
            <input type="checkbox" name="checkbox" id="checkbox" />
            <input type="hidden" name="part" id="part" value="67890" />
            <input type="hidden" name="lc" id="lc" value="DDD" />
        </td>
        <td>Qty:
            <input type="text" name="qty" id="qty" value="1" size="2" />
            <td width="80%">DDD 67890</td>
    </tr>
    <tr id="5">
        <td width="20%">
            <input type="checkbox" name="checkbox" id="checkbox" />
            <input type="hidden" name="part" id="part" value="45678" />
            <input type="hidden" name="lc" id="lc" value="EEE" />
        </td>
        <td>Qty:
            <input type="text" name="qty"...

JavaScript

$("#button").click(function () { // click it
    var str = []; // empty array
    $(":checkbox:checked").each(function () { // loop through all checked checkboxes
        var parent = $(this).closest("tr"); // select each checkbox parent table row
        $(parent).each(function () { // loop through all checked parent table rows
            part = $(this).find("td:first :input:nth-child(2)").val(); // value of part number from second input
            line = $(this).find("td:first :input:nth-child(3)").val(); // value of line code from third input
            qty = $(this).find("td:nth-child(2) :input").val(); // value of qty, second td
            var values = part + "," + line + "," + qty; // create a varible of all to push
            str.push(values); // push each value group to array
        }); // parent each
    }); // checbox each
    var strValues = str.join(";"); // join it together separated by a semi colon for the value
    alert(strValues); // poof, values
}); // click function