FreeMarker 页面动态加载多个select下拉,并根据select id,取得对应的信息
<tbody id="productCategory">
<tr>
<th width="5%">
<img src="../img/add.png" onClick="addProdPricTr();"/>
</th>
<th colspan="2">商品分类</th>
</tr>
<#assign count=0>
<#list categroyMaps?if_exists as category>
<tr id="trProPric${category_index+1}">
<td>
<img src="../img/delete.png" onClick="removeTd('${category_index+1}')"/>
<td>
<font color="red">* </font>
<SELECT id="categoryIds${category_index+1}" name="categoryIds" style="width: 150px" οnchange="ChangeCategory('${category_index+1}')">
<option value="">--选择分类--</option>
<#list allCategroys as cate>
<option value="${cate.id}" <#if cate.id == category.categoryId>selected</#if>>
<#if cate.categoryLevel==1>
<#else>
<#list 1..cate.categoryLevel as a>-</#list>
</#if>
${(cate.categoryName)!}
</option>
<#assign count= category_index + 1>
</#list>
</select>
</td>
<td>
<font color="red">* </font>品类:<input type="text" id="categoryNames${category_index+1}" name="categoryNames" value="${(category.categoryName)!}" readonly="readonly" >
标签名: <input type="text" id="tagNames${category_index+1}" name="tagNames" value="${(category.prodTagName)!}" readonly="readonly" >
<script type="text/javascript" src="${base}/js/jquery-1.4.2.min.js"></script>
<script>
var id = "${count}";
var idd = "${category.categoryId}";
$.ajax({
type: "post",
url: "/product/getProdTagByCategoryId.action",
data: "category.id="+idd,
success: function(msg){
$("#tagNames"+id).val(msg);
}
});
</script>
</td>
</tr>
</#list>
</tbody>
</table>
<tbody id="productCategory">
<tr>
<th width="5%">
<img src="../img/add.png" onClick="addProdPricTr();"/>
</th>
<th colspan="2">商品分类</th>
</tr>
<#assign count=0>
<#list categroyMaps?if_exists as category>
<tr id="trProPric${category_index+1}">
<td>
<img src="../img/delete.png" onClick="removeTd('${category_index+1}')"/>
<td>
<font color="red">* </font>
<SELECT id="categoryIds${category_index+1}" name="categoryIds" style="width: 150px" οnchange="ChangeCategory('${category_index+1}')">
<option value="">--选择分类--</option>
<#list allCategroys as cate>
<option value="${cate.id}" <#if cate.id == category.categoryId>selected</#if>>
<#if cate.categoryLevel==1>
<#else>
<#list 1..cate.categoryLevel as a>-</#list>
</#if>
${(cate.categoryName)!}
</option>
<#assign count= category_index + 1>
</#list>
</select>
</td>
<td>
<font color="red">* </font>品类:<input type="text" id="categoryNames${category_index+1}" name="categoryNames" value="${(category.categoryName)!}" readonly="readonly" >
标签名: <input type="text" id="tagNames${category_index+1}" name="tagNames" value="${(category.prodTagName)!}" readonly="readonly" >
<script type="text/javascript" src="${base}/js/jquery-1.4.2.min.js"></script>
<script>
var id = "${count}";
var idd = "${category.categoryId}";
$.ajax({
type: "post",
url: "/product/getProdTagByCategoryId.action",
data: "category.id="+idd,
success: function(msg){
$("#tagNames"+id).val(msg);
}
});
</script>
</td>
</tr>
</#list>
</tbody>
</table>