【发布时间】:2022-01-21 16:48:12
【问题描述】:
我被困在用于在 javascript/jquery 中完成此任务的逻辑上,如果有人有任何想法,我可以使用一些帮助。
我有一张表格,显示发票上产品的每件商品成本。
目标是按类别查找所有产品(目前是 shirtcountrow 和 hoodiecountrow,但以后会有更多)并将具有相同值的产品组合起来。
当前表格如下所示:
<table id="productmathtable">
<tr>
<td>Shirt</td>
<td><input class="shirtcountrow" type="text" value="4" style="width:60px"> x <input class="productpricerow" type="text" value="25" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="100" style="width:60px"></td>
</tr>
<tr>
<td>Shirt</td>
<td><input class="shirtcountrow" type="text" value="2" style="width:60px"> x <input class="productpricerow" type="text" value="25" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="50" style="width:60px"></td>
</tr>
<tr>
<td>Shirt</td>
<td><input class="shirtcountrow" type="text" value="2" style="width:60px"> x <input class="productpricerow" type="text" value="25" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="50" style="width:60px"></td>
</tr><tr>
<td>Hoodie</td>
<td><input class="hoodiecountrow" type="text" value="4" style="width:60px"> x <input class="productpricerow" type="text" value="35" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="140" style="width:60px"></td>
</tr>
<tr>
<td>Hoodie</td>
<td><input class="hoodiecountrow" type="text" value="4" style="width:60px"> x <input class="productpricerow" type="text" value="35" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="140" style="width:60px"></td></tr>
</table>
我希望它在执行 jquery/javascript 函数后看起来像这样:
<table id="productmathtable">
<tr>
<td>Shirt</td>
<td><input class="shirtcountrow" type="text" value="8" style="width:60px"> x <input class="productpricerow" type="text" value="25" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="200" style="width:60px"></td>
</tr>
<td>Hoodie</td>
<td><input class="hoodiecountrow" type="text" value="8" style="width:60px"> x <input class="productpricerow" type="text" value="35" style="width:60px"> = </td>
<td class="tabletotalrow"><input class="productotalrow totalrow" type="text" value="280" style="width:60px"></td>
</tr>
</table>
我很确定我需要更改我的 html,以便更容易识别我想要更改的每个部分,但我不确定如何
【问题讨论】:
标签: javascript html jquery forms