Struts 1使用jsp中的display标签删除确认

时间:2013-04-24 20:06:51

标签: javascript html jsp struts displaytag

我试图在用户点击display:列中的删除按钮后显示删除确认框。我有对话框显示但是一旦用户确认他想删除动作没有被调用。该页面只是在没有删除行的情况下重新加载。如果没有删除确认,该行将被成功删除。我做错了确认。任何帮助将不胜感激,谢谢

我现在拥有的是:

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>

1 个答案:

答案 0 :(得分:0)

您尚未在html中指定表单名称。你在哪里提到过表格标签中的“myForm”名称?

<form name="myForm" .. >