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

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -