从表格中的call元素中选择3rd

时间:2013-02-11 21:58:08

标签: jquery html-table

我知道这可能很容易,但我无法理解。我需要创建级联选择框,但我不知道如何引用来自调用选择的目标选择框。我试过了:

$(this).next().next().next().html(data)

但这不起作用。我怀疑这对父母的孩子有所帮助。

编辑:这是HMTL

<table id="invoiceTable">
<tr>
    <th></th>
    <th class="productColumn">Product</th>
    <th class="lotColumn">Lot #</th>
    <th class="wheelColumn">Wheel #</th>
    <th class="packageType">Pkg Type</th>
    <th class="quantityField">Weight</th>
    <th class="priceColumn">Price</th>
    <th class="subTotalColumn">Subtotal</th>
    <th class="soldOut">Sold Out</th>
</tr>
<?php
if(!$newInvoice){ $rowNum = 0;
    foreach($details as $detail){ /* @var $detail Creamery_Invoice_details */?>


<tr>
    <td><button type="button" class="delete">D</button></td>
    <td class="productColumn">

        <select name="productInputName[]" class="productSelect" id="cheeseName">
            <option></option>

        </select>

    </td>

    <td>
        <select name="lotNumber[]" class="lotNumber" >
            <option value=0>Lot #</option>

        </select>
    </td>
    <td>
        <select name="wheelNumber[]" class="wheelNumber">
            <option value=0>Wheel</option>

                </select>

            </td>


            <td>
            <select name="packageType[]" class="packageType">
            <option value=0>Pkg Type</option>

        </select>
    </td>

    <td class="quantityField"><input name="quantity[]" type="number"> <?php echo ' value="',$detail->getQuantity(),'"';   ?>></td>
    <td class=priceField><input name="price[]" type="number" step="any">

    </td>
    <td class="subtotalField"><input type="number" step="any" readonly="readonly"></td>
    <td class="soldOut"><input type="checkbox" name="soldOut[]" <?php if($detail->getSoldOut()){echo 'checked="checked"';} ?> ></td>

</tr>

编辑2:我只是想添加,以防其他人遇到此问题,$(this).whatever无效,因为它在ajax调用中我需要这样做:

$(".productSelect").change(function(){
    var product = this;
    $.get("/path to php file", 'type='+$(this).val(),function(data){
        $(product).closest('tr').find('.lotNumber').html(data);
    })
});

1 个答案:

答案 0 :(得分:1)

您可以使用productSelect packageType中的第3个选择类。

见下文,

$(this).closest('tr').find('.packageType').html(data)