我有一個表格,其中包括具有下面基本結構的輸入文本字段。我無法構建一個迭代表中所有行的函數,並總結以BFObel開頭的輸入字段的所有值,其中以BFOkto開頭的字段的值相同。因此,以價值爲1111總和低於基本的例子是,2000和1112的值的總和將是3000然後,每個總和將被寫入到inputfield用id field1111,field1112等等jquery:求和輸入文本字段
<table>
<tr id="BFOrow1">
<td><input type="text" id="BFOtxt1" value="text"/></td>
<td><input type="text" id="BFOkto1" value="1111" /></td>
<td><input type="text" id="BFObel1" value="1000" /></td>
</tr>
<tr id="BFOrow2">
<td><input type="text" id="BFOtxt2" value="text"/></td>
<td><input type="text" id="BFOkto2" value="1111" /></td>
<td><input type="text" id="BFObel2" value="1000" /></td>
</tr>
<tr id="BFOrow3">
<td><input type="text" id="BFOtxt3" value="text"/></td>
<td><input type="text" id="BFOkto3" value="1112" /></td>
<td><input type="text" id="BFObel3" value="1000" /></td>
</tr>
<tr id="BFOrow4">
<td><input type="text" id="BFOtxt4" value="text"/></td>
<td><input type="text" id="BFOkto4" value="1112" /></td>
<td><input type="text" id="BFObel4" value="1000" /></td>
</tr>
<tr id="BFOrow5">
<td><input type="text" id="BFOtxt5" value="text"/></td>
<td><input type="text" id="BFOkto5" value="1112" /></td>
<td><input type="text" id="BFObel5" value="1000" /></td>
</tr>
</table>
您需要更好地說出您的問題併發布一些html – Calum 2011-04-17 19:34:00
由於您正在計算幾筆款項,您打算如何處理結果?他們應該如在數組中返回,還是作爲屬性/數據存儲在行本身中? – 2011-04-17 19:38:25
每個總和將被寫入另一個輸入字段,其ID爲1111或1112 – 2011-04-17 19:40:59