2017-07-28 1 views
1

私はJSTLタグを持つjspページを持っています.JSPページには2つの異なるタブがあります。ユーザーが最初のタブをクリックすると、値のリストを含むtbodyで表を表示します。ユーザーが2番目のタブをクリックしたときにc:forEach項目を変更したいと思います.2つのタブリストには同じ値のパラメータが含まれています.c:forEachの項目をjavascriptで変更する必要があります。これは可能ですか? JSP変更c:forEachリスト項目javacriptを使用

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

であなたに

に感謝

私はJavaScriptを使用して

項目に項目= "$ {S1Listを}" に変更したい= "$ {S2List}" のJavascript

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>'); 
    }); 
    } 
}); 

最初のタブをクリックしたときと同じようにしてください。

関連する問題