2017-07-28 78 views
1

我有一个jsp页面与JSTL tags.jsp页面包含2个不同tab.If用户单击第一个选项卡,然后要显示与tbody包含值列表的表。罚款。现在我想改变c:forEach项目,当用户点击第二个选项卡。两个选项卡列表包含相同的参数与不同的值。所以我需要改变c:forEach项目使用javascript。这可能吗 ?更改c:forEach列表项目使用javascript

感谢你

在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> 

我想= “$ {S2List}” 使用JavaScript

的Javascript

更改的项目= “$ {S1List}” 项
funcion changevalueWhenSecondTabclick(){ 
//I want the solution code here 
} 

回答

1

你可以使用Jquery实现这个功能。您应该将S2List存储在jQuery变量中。在我看来,我如下

$(document).ready(function() { 
    //This part let's you to store the list in Java script variable 
    var list2ObjectValue="${S2List}"; 

    funcion changevalueWhenSecondTabclick(){ 
    //I want the 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>'); 
    }); 
    } 
}); 

尝试以同样的方式被点击第一个选项卡时,将实现这一目标。