Jquery 更改选择选项时如何更改输入值?

Jquery 更改选择选项时如何更改输入值?,jquery,woocommerce,Jquery,Woocommerce,我有一张如下的桌子。动态选择框和数量输入ID。但我知道每个桌子的tr id。如果选择change,我希望更改同一行上的所有输入值。示例:如果选择选项“值等于1”,则所有输入值(如1 2 1)都是同一行 | size/color | xs | s | m | l | xl | |:-----------|:---|:--|:--|:--|:---| |Blue <br><b>SELECTBOX 1</b>|input 1|input 2|input 3|inpu

我有一张如下的桌子。动态选择框和数量输入ID。但我知道每个桌子的tr id。如果选择change,我希望更改同一行上的所有输入值。示例:如果选择选项“值等于1”,则所有输入值(如1 2 1)都是同一行

| size/color | xs | s | m | l | xl |
|:-----------|:---|:--|:--|:--|:---|
|Blue <br><b>SELECTBOX 1</b>|input 1|input 2|input 3|input 4|input 5|
|Yellow <br><b>SELECTBOX 2</b>|input 6|input 7|input 8|input 9|input 10|
|Red <br><b>SELECTBOX 3</b>|input 11|input 12|input 13|input 14|input 15|
|Black <br><b>SELECTBOX 4</b>|input 16|input 17|input 18|input 19|input 20|
|尺寸/颜色| xs | s | m | l | xl|
|:-----------|:---|:--|:--|:--|:---|
|蓝色
选择框1 |输入1 |输入2 |输入3 |输入4 |输入5| |黄色
选择框2 |输入6 |输入7 |输入8 |输入9 |输入10| |红色
选择框3 |输入11 |输入12 |输入13 |输入14 |输入15| |黑色
选择框4 |输入16 |输入17 |输入18 |输入19 |输入20|
我的代码是

<table id="wbv_f393cdad063d564d_1" class="wc-bulk-variations-table nowrap" width="100%">
    <thead>
        <tr>
            <th class="col-pa_bedenpa_renk">Beden / Renk</th>
            <th class="col-xs">XS</th>
            <th class="col-s">S</th>
            <th class="col-m">M</th>
            <th class="col-l">L</th>
            <th class="col-xl">XL</th>
        </tr>
    </thead>
    <tbody>
        <tr id="product-row-mavi">
            <td>
                <span class="no-image">Mavi</span>
                <p>
                    <select class="form-control" id="product-row-mavi-lot">
                        <option>Lot Seçiniz</option>
                        <option val="1">Lot 1</option>
                        <option val="2">Lot 2</option>
                    </select>
                </p>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="24" type="number" id="quantity_24" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="27" type="number" id="quantity_27" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                    <span class="woocommerce-Price-amount amount">
                        <bdi>15,00&nbsp;
                            <span class="woocommerce-Price-currencySymbol">₺</span>
                        </bdi>
                    </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="30" type="number" id="quantity_30" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="33" type="number" id="quantity_33" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="36" type="number" id="quantity_36" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                    <span class="woocommerce-Price-amount amount">
                        <bdi>15,00&nbsp;
                            <span class="woocommerce-Price-currencySymbol">₺</span>
                        </bdi>
                    </span>
            </td>
        </tr>
        <tr id="product-row-sari">
            <td>
                <span class="no-image">Sarı</span>
                <p>
                    <select class="form-control" id="product-row-sari-lot">
                        <option>Lot Seçiniz</option>
                        <option val="1">Lot 1</option>
                        <option val="2">Lot 2</option>
                    </select>
                </p>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="25" type="number" id="quantity_25" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="28" type="number" id="quantity_28" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="31" type="number" id="quantity_31" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="34" type="number" id="quantity_34" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
            <td>
                <input data-individual="0" data-table_id="wbv_f393cdad063d564d_1" data-price="15" data-product_id="37" type="number" id="quantity_37" class="wcbvp_quantity" step="1" min="0" max="99" name="quantity" value="0" title="Qty" size="4" inputmode="numeric">
                <span class="woocommerce-Price-amount amount">
                    <bdi>15,00&nbsp;
                        <span class="woocommerce-Price-currencySymbol">₺</span>
                    </bdi>
                </span>
            </td>
        </tr>
    </tbody>
</table>

贝登/伦克
XS
s
M
L
特大号
马维

第三批
标段1
标段2

15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺ 萨尔ı 第三批 标段1 标段2

15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺
您可以使用最近的

我做了一个查找表

const查找={
“mavi”:[
[0, 0, 0, 0, 0],
[1, 1, 2, 3, 1],
[2, 1, 3, 2, 1]
],
“莎丽”:[
[0, 0, 0, 0, 0],
[2, 3, 2, 2, 3],
[1, 1, 1, 2, 1]
]
}
document.querySelector(“表tbody”).addEventListener(“更改”,函数(e){
常数tgt=e.target;
if(tgt.id.startsWith(“产品行”)){
const color=tgt.id.match(/row-(\w+)-lot/)[1]
const row=tgt.最近的(“tr”);
const inputs=row.querySelectorAll(“输入[名称=数量]”)
const vals=lookup[color][tgt.selectedIndex]
vals.forEach((val,i)=>输入[i].value=val)
}
})

贝登/伦克
XS
s
M
L
特大号
马维

第三批
标段1
标段2

15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺ 萨尔ı 第三批 标段1 标段2

15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺ 15,00 ₺
将值更改为什么?输入1=1输入2=1输入3=2输入4=2输入5=1您在哪里看到蓝色、黄色、红色?演示在这里:此代码给出了数据价格,但我希望5个输入值逐个更改1,2,2,1,现在我知道了。不清楚。当有人更改下拉列表时,为什么要更改数量?无论如何,请参阅更新,因为只能选择此产品包。因此,如果用户选择“标段1”,他实际上可以得到1x、2s、2m、1l、1xl。现在我明白了。请查看已更改的脚本。谢谢。此代码正在运行。但我们的id产品行XXX动态。我能自动得到这个并添加代码吗?