2013-04-24 84 views
1

當用戶單擊display:列中的刪除按鈕時,我試圖顯示一個刪除確認框。我有對話框顯示出來,但一旦用戶確認他想刪除該操作沒有被調用。該頁面只是在不刪除行的情況下重新加載。沒有刪除確認,該行將被成功刪除。我做了錯誤的確認。任何幫助,將不勝感激,謝謝Struts 1使用jsp中的顯示標籤刪除確認

我有現在的問題是:

的jQuery:

$(".btnShowDeleteConfirmation").click(function (e) 
      { 
      ShowDialog(true); 
      e.preventDefault(); 
      }); 

      $("#btnClose, #btnNo").click(function (e) 
      { 
      HideDialog(); 
      e.preventDefault(); 
      }); 

      $("#btnYes").click(function (e) 
      { 

      }); 

的Javascript:

function deleteEntry(rowId) 
    { 
    document.getElementById('rowId').value=rowId; 
    document.forms['myForm'].action='/myAction/deleteAction.action?method=deleteRow'; 
    document.forms['myForm'].submit;  
    } 

顯示標籤表:

<form action="" method="POST" id="mainForm" name="MyFormBean"> 

<display:table requestURIcontext="true" requestURI="/unavailability/loadUnavailability.action?method=loadForm" uid="myList" name="requestScope.unavailList" class="simple" pagesize="10" defaultsort="2" sort="list" cellspacing="0" excludedParams="*">  

<display:column property="startDate" title="Start Date" width="18%" decorator="com.mhngs.util.DisplayTagDateWrapper" sortable="true" headerClass="sortable"/> 
<display:column property="endDate" title="End Date" width="18%" decorator="com.mhngs.util.DisplayTagDateWrapper" sortable="true" headerClass="sortable" /> 
<display:column property="reason" title="Comments" width="30%" sortable="true" headerClass="sortable" /> 

<display:column media="html" width="10%" class="btnShowDeleteConfirmation"> 
<a href="#">Delete</a> 
</display:column> 


</display:table> 
<input type="hidden" name="rowId" id="rowId" /> 
</form> 

HTML :一旦用戶點擊刪除按鈕,就會顯示此項

<div id="overlay" class="delete_overlay"></div> 

     <div id="dialog_delete" class="delete_overlay"> 
     <form method="post" action=""> 
      <table style="width: 100%; border: 0px;" cellpadding="3" cellspacing="0"> 
       <tr> 
        <td class="web_dialog_title">Delete Row Confirmation</td> 
        <td class="web_dialog_title align_right"><a href="#" id="btnClose">Close</a></td> 
       </tr> 
       <tr> 
        <td>&nbsp;</td> 
        <td>&nbsp;</td> 
       </tr> 
       <tr> 
        <td colspan="2" style="padding-left: 15px;"> 
         <label>You seleted a row to be deleted</label> 
        </td> 
       </tr> 
      <tr> 
      <td>&nbsp;</td> 
      <td>&nbsp;</td> 
      </tr> 
      <tr> 
      <td colspan="2" style="text-align: center;"> 
       <input id="btnYes" type="submit" value="Yes" onClick="javascript:deleteEntry('<c:out value="${myList.rowId}"/>')"/> 
       <input id="btnNo" type="button" value="No" /> 
      </td> 
      </tr> 
      </table> 
     </form> 
    </div> 

回答

0

您還沒有在html中指定表單名稱。你在表單標籤中提到了「myForm」的名字?

<form name="myForm" .. >