0

我知道这可能很容易,但我无法弄清楚。我需要创建级联选择框,但我不知道如何引用距离调用选择超过 3 的目标选择框。我试过了:

$(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);
    })
});
4

1 回答 1

1

您可以使用第 3 个选择的类,productSelect其中 is packageType

见下文,

$(this).closest('tr').find('.packageType').html(data)
于 2013-02-11T22:09:09.010 回答