0

現在のフィールドのすぐ次の選択ボックスの値のみを変更しようとしています。

フォームは、同じクラスを持つフィールドを持つ行の長いリストです。「行1」の「数量」フィールドにフォーカスして、「タイプ」選択ボックスを同じ行の「ボックス」に変更したいと思います。私が試したすべてのコードは、ページ全体のすべての「タイプ」選択ボックスを変更します。数量フィールドに最も近い、最も近いものだけを変更したい。

UOMフィールドは、ユーザーが数量に注目したときに変更しようとしているフィールドです。

ありがとう!

<tr class="draggable odd">
<td class="content-multigroup-cell-field-part-num">
    <div id="edit-group-order-0-field-part-num-value-wrapper" class="form-item">
        <label for="edit-group-order-0-field-part-num-value">J&amp;B No.: 
        </label>
        <input type="text" class="form-text text idleField" value="" size="10" id="edit-group-order-0-field-part-num-value" name="group_order[0][field_part_num][value]" pattern="[0-9]*">
    </div>
</td>
<td class="content-multigroup-cell-field-quantity">
    <div id="edit-group-order-0-field-quantity-value-wrapper" class="form-item">
        <label for="edit-group-order-0-field-quantity-value">Quantity: 
        </label>
        <input type="text" class="form-text text idleField" value="" size="5" id="edit-group-order-0-field-quantity-value" name="group_order[0][field_quantity][value]" pattern="[0-9]*">
    </div>
</td>
<td class="content-multigroup-cell-field-quantity-type">
    <div id="edit-group-order-0-field-quantity-type-value-wrapper" class="form-item">
        <label for="edit-group-order-0-field-quantity-type-value">UOM: 
        </label>
        <select id="edit-group-order-0-field-quantity-type-value" class="form-select" name="group_order[0][field_quantity_type][value]">
            <option selected="selected" value="">- None -
            </option>
            <option value="Box(es)">Box(es)
            </option>
            <option value="Case(s)">Case(s)
            </option>
            <option value="Each">Each
            </option>
            <option value="Feet">Feet
            </option>
        </select>
    </div>
</td>

J&B番号:数量:単位:-なし-ボックスケース各フィート

4

2 に答える 2

0

最も近いものを試しましたか?

于 2010-07-17T18:25:28.510 に答える
0

テーブル マークアップを使用していて、td 内の要素のフォーカス イベント内にいると想定しています。

$('input.quantity').focus( function() {
    //get current cell, find nearest select.type in the following siblings
    $(this).parent()
           .nextAll()
           .find('select.type:first').val('boxes');

});
于 2010-07-17T18:27:08.120 に答える