jquery - How to pass id of each item in for loop to javascript function? -
i need add id of each item function of onchange event, <select> tag not accept expression.
once user selects category list, id of associated item along value of should sent ajax sent back-end.
<c:foreach var="item" items="${items}"> ..... <s:select id="name" name="name" list="@interfaces.lists@category" value="item.category" onchange='changeitemcategory(${item.id},this.value)' /> </c:foreach> it not accept %{item.id} well, when try item.id sends request function proid variable's value 'undefined'.
<script> function changeitemcategory(proid,cat){ alert(proid+cat); ..... } </script> error:
according tld or attribute directive in tag file, attribute `onchange` not accept expressions.
use ognl, not jsp el:
onchange='changeitemcategory(%{#item.id}, this.value)'
Comments
Post a Comment