2017-11-27 7 views
0

JavaサーブレットをオブジェクトとしてOracleからデータを取得することで、jspで動的にテーブルを作成しています。私の目的は、row numの値を別のJavaサーブレットに送ることによって、行を編集することです。私は下の例のalertの値を表示しようとしていますが、その行の最後の値だけを元に戻しています。ご協力いただきありがとうございます!JavaScriptのforループの外にあるJavaオブジェクトの値を取得する

コードスニペット& javascript。 crObject.getRefNum()の値をJavaサーブレットに送信することを目指します。これは、JSPで行われている

<div class="container"> 
    <table class="table"> 
    <th>Ref #</th> 
    <th>CR #</th> 
    <th>Imapcted Application</th> 
    <th>Deployment Starts</th> 
    <th>Deployment Ends</th> 
    <th>Issue Description</th> 
    <th>Approval Status</th> 
    <th>Edit</th> 


    <% 
CRDetails crObject; 
for (int i = 0; i < listLength; i++) 
{ 
    crObject = (CRDetails) Alldata.get(i); 
    out.println("<tr><td>" + crObject.getRefNum() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getCrNum() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getAppName() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getDeployStartTime() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getDeployEndTime() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getIssueDesc() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getStatus() + "</td>" + "\n"); 
    pageContext.setAttribute("refNum",crObject.getRefNum()); 
// pageContext.setAttribute("refNum",11); 

%> 
     <td><a editid="<%=crObject.getRefNum()%>" href="javascript:editRow()" target="_blank">Edit</a>${crObject.getRefNum()}</td> 

     <!--<c:out value = '${refNum}' />--> 
     <%  
} 


    %> 
テーブルの

ビジュアルビュー:として動的に編集するのhrefを変更 enter image description here

答えて

0

のJavascriptのようにmodifedた
<td><a name = "listLength1" id = "listLength1" value ="<%=crObject.getRefNum()%>" type = int href="javascript:editRow('<%=crObject.getRefNum()%>')" target="_blank">Edit</a></td> 

<script>function editRow(listLength1) {alert(listLength1); 
関連する問題