jsp - change c:forEach list items using javascript -
i have jsp page jstl tags.the jsp page contain 2 different tab.if user click first tab,then want show table tbody contain list of values.that works fine.now want change c:foreach items when user click second tab.the 2 tab list contain same parameters different values.so need change items of c:foreach using javascript. possible ?
thanking you
in jsp
<table id="dynamic-table"> <thead> <tr> <th>sl.no.</th> <th class="sorting_disabled">loan id</th> <th class="sorting_disabled">name</th> </tr> </thead> <tbody> <c:foreach var="mainlist" items="${s1list}" varstatus="status"> <tr> <td class="center">${status.index + 1}</td> <td>${mainlist.loanid}</td> <td>${mainlist.name}</td> </tr> </tbody> </table>
i want change items="${s1list}" items="${s2list}" using javascript
javascript
funcion changevaluewhensecondtabclick(){ //i want solution code here }
you can able achieve using jquery. should store s2list in jquery variable. in view achieve follows
$(document).ready(function() { //this part let's store list in java script variable var list2objectvalue="${s2list}"; funcion changevaluewhensecondtabclick(){ //i want solution code here $('#dynamic-table tbody').empty(); $.each( list2objectvalue, function( index, value ){ $('#dynamic-table').append('<tr>' +'<td class="center">' + index + '</td>' +'<td>' + value.loanid + '</td>' +'<td>' + value.name + '</td>' +'</tr>'); }); } });
try same way when 1st tab clicked.
Comments
Post a Comment