我有一个表格,其中有几行。每一行都有一个产品字段、一个等级字段和一个家庭字段。
然后为每个可用尺寸提供了几个复选框。
表格中的一行看起来像这样:
<table class="authors-list" border=0 id="ordertable">
<tr>
<td style="font-size:10px;"><a class="deleteRow"> <img src="<?php echo base_url() ?>application/assets/images/delete2.png" /></a></td>
<td ><input type="text" id="product1" name="product1" class="rounded"/></td>
<td ><input type="text" size='5' id="qty1" name="qty1" class="rounded"/></td>
<td class="tdcheckbox">
<input type="checkbox" id="h09_1" name="h09_1" class="rounded"/>
<input type="text" id="line_1_09" name="line_1_09" value="">
<input type="text" id="size_1_09" name="size_1_09" value="09">
</td>
<td class="tdcheckbox">
<input type="checkbox" id="h12_1" name="h12_1" class="rounded"/>
<input type="text" id="line_1_12" name="line_1_12" value="">
<input type="text" id="size_1_12" name="size_1_12" value="12">
</td>
<td class="tdcheckbox">
<input type="checkbox" id="h15_1" name="h15_1" class="rounded"/>
<input type="text" id="line_1_15" name="line_1_15" value="">
<input type="text" id="size_1_15" name="size_1_15" value="15">
</td>
<td><input type="text" name="cubespercheck_1" id="cubespercheck_1" value="0" size=5></td>
<td><input type="text" name="skufamily_1" id="skufamily_1"></td>
<td><input type="text" name="skugrade_1" id="skugrade_1"></td>
</tr>
</table>
<input type="button" id="continue" value="continue">
除产品字段外,所有字段将在最终结果中隐藏。
为了让您了解背景,我的产品代码如下所示:3811460S5。38114是宽度和高度,60是长度,Cr是等级。
我想要的是,当我点击按钮时,jquery必须循环遍历所有表格单元格。如果复选框被勾选且产品已填写,则jquery必须将字段连接起来,如下所示:skufamily(对于行[skufamily])+ 长度(来自单元格[size])+ 等级(来自行[skugrade])。
此结果必须填充当前的td输入线路
。因此现在每个单元格都将有一个精确的sku(仅在勾选并填充产品时)。
skufamily、size和grade是预填的,所以只需要用jquery循环和连接这些字段。
这里有一个可以操作的示例:http://jsfiddle.net/QS56z/
我尝试过以下概念,但无法完全掌握代码。
function createcodes() {
$("table.authors-list").find('input[type="checkbox"][name^="h"]:checked').each(function () {
if (<checkbox is checked>)
document.getElementById(input[type="skufamily").value +
document.getElementById(input[type="size").value +
document.getElementById(input[type="skugrade").value
});
这远远不正确,如果您能引导我走正路,我将不胜感激。
一如既往,非常感谢。