如何从不同的<div> </div>中删除数据

时间:2015-03-20 12:05:55

标签: java html

我在单页上加载了两个<div>,两者都持有相同的用户ID。我想从第二个<div>删除用户数据。这怎么可能。这是我的删除控制器代码..

HTML

<div id="tab1">

      <br/>

      <font color="#3b73af" size="4">Partner Detail</font>

#if($editPartnerDetail)  
 <form id="editPartnerDetail" class="aui" onsubmit="return validateEditForm()">
        <div id="Partner_Detail">
        <table style="width:80%;border:none;" cellspacing="0" cellpadding="0">
        <tr>
        <td>Admin Name:</td><td><input type="text" value="$editPartnerDetail.adminName" id="editAdminName" name="editAdminName" size="55" /></td>
        </tr>
        <tr>
        <td>Email:</td><td><input type="text" value="$editPartnerDetail.email" id="editEmail" name="editEmail" size="55" /></td>
        </tr>
        <tr>
        <td>Phone:</td><td><input type="text" value="$editPartnerDetail.phone" id="editPhone" name="editPhone" size="55" /></td>
        </tr>
        <input type="hidden" value="$editPartnerDetail.partnerDetailId" id="editPartnerDetailId" name="editPartnerDetailId" size="55" />
        <input type="hidden" value="$editPartnerDetail.partnerSiteId" id="editPartnerSiteId" name="editPartnerSiteId" size="55" />
        <tr>
        <td></td><td><input type="submit" value="Update" class="button" /> &nbsp; &nbsp; <a href="/plugins/servlet/lrnadmin/partner?page=partnerDetail&siteId=$editPartnerDetail.partnerSiteId" class="button">Cancel</a></td>
        </tr>
        </table>    
    </div> <br/><br/><br/>
  </form>
#else  
 <form id="addPartnerDetail" class="aui" onsubmit="return validateForm()">
        <div id="Partner_Detail">
        <table style="width:80%;border:none;" cellspacing="0" cellpadding="0">
        <tr>
        <td>Admin Name:</td><td><input type="text" value="" id="adminName" name="adminName" size="55" autocomplete="off"/></td>
        </tr>
        <tr>
        <td>Email:</td><td><input type="text" value="" id="email" name="email" size="55" autocomplete="off"/></td>
        </tr>
        <tr>
        <td>Phone:</td><td><input type="text" value="" id="phone" name="phone" size="55" autocomplete="off"/></td>
        </tr>
        <input type="hidden" value="$siteId" id="addPartnerSiteId" name="addPartnerSiteId" size="55" />
        <tr>
        <td></td><td><input type="submit" value="Add" class="button" /></td>
        </tr>
        </table>    
    </div> <br/><br/><br/>
  </form>
#end
  <div id="Partner_Detail">
        <table style="width:80%">
          <tr>
            <th bgcolor="#F2F5A9">Admin Name</th>
            <th bgcolor="#F2F5A9">Email</th>    
            <th bgcolor="#F2F5A9">Phone</th>
            <th bgcolor="#F2F5A9">Action</th>   
          </tr>
            #foreach( $partnerDetail in $partnerDetailList )
          <tr>
            <td>$partnerDetail.adminName</td>
            <td>$partnerDetail.email</td>
            <td>$partnerDetail.phone</td>
            <td align="center"><a href="/plugins/servlet/lrnadmin/partner?page=partnerDetail&mode=edit&pdId=$partnerDetail.partnerDetailId&nameId=$partnerDetail.partnerSiteId">Edit</a> | <a href="/plugins/servlet/lrnadmin/partner?page=partnerDetail&mode=delete&pdId=$partnerDetail.partnerDetailId&nameId=$partnerDetail.partnerSiteId" onclick="return confirm_click();">Delete</a></td> 
          </tr>
          #end
        </table>
  </div>

</div>

<div id="tab2">

        #if($editPartnerSite2)
        <form id="editsite2" class="aui">
             <div id="edit_Partner_site2">
              <input type="text" value="$editPartnerSite2.partnerSite" id="editPartnerSite" name="editPartnerSite" size="55" />
            <input type="hidden" value="$editPartnerSite2.partnerId" id="editPartnerSiteId" name="editPartnerSiteId" size="55" />
            <input type="hidden" value="site" id="page" name="page" size="55" />


            <input type="submit" value="Update" class="button">
            <a href="/plugins/servlet/lrnadmin/partner?page=partnerDetail" class="button">Cancel</a>
             #if($isSiteupdated == false)
            <div style="color:red;">Cannot Edit. Same partner site already exist.</div>
            #end
             </div> 

            </br>
         </form>
        #else
        <form id="addsite" class="aui">
        <div id="add_Partner_Site">
            <input type="hidden" value="site" id="page" name="page" size="55" />
            <input type="text" id="partnersite" name="partnersite" size="55" autocomplete="off" value="$!existingSite"/>
            <br/><br/><input type="submit" value="Add" class="button" /></td>

            #if($isSiteAdded == false)
            <div style="color:red;">Cannot add. Same partner site already exist.</div>
            #end
        </div> <br/><br/><br/>
        </form>

        #end

        <table>
          <tr>
            <th bgcolor="#F2F5A9">Partner Site</th>
            <th bgcolor="#F2F5A9">Action</th>       
          </tr>
           #foreach( $partnerSite in $partnerSiteList )
          <tr>
            <td>$partnerSite.partnerSite</td>   
            <td align="center"><a href="/plugins/servlet/lrnadmin/partner?page=partnerDetail&mode=editTab2&sId=$partnerSite.partnerSiteId">Edit</a> | <a href="/plugins/servlet/lrnadmin/partner?page=partnerDetail&mode=deleteTab2&sId=$partnerSite.partnerSiteId" onclick="return confirm_click();">Delete</a></td>   
          </tr>
          #end
         </table>
<div>

控制器

else if (pageName != null && pageName.equals("partnerDetail")) {
        Map<String, Object> context = new HashMap<String, Object>();
        if (request.getParameter("nameId") != null && request.getParameter("nameId") != "") {
            siteId = Integer.parseInt(request.getParameter("nameId"));
            String mode = request.getParameter("mode");
            if (mode != null && mode.equals("delete")) {
                String pdId = request.getParameter("pdId");
                if (pdId != null && pdId != "") {
                    partnerDetailService.deletePartneDetail(Integer.parseInt(pdId));
                }
            }

            if (mode != null && mode.equals("edit")) {
                String pdId = request.getParameter("pdId");
                int partnerDetailID = Integer.parseInt(pdId);
                if (pdId != null && pdId != "") {
                    PartnerDetail editPartnerDetail = partnerDetailService.getPartneDetailById(partnerDetailID);
                    context.put("editPartnerDetail", editPartnerDetail);
                }
            }
        }

        if (request.getParameter("nameId") != null && request.getParameter("nameId") != "") {
            siteId = Integer.parseInt(request.getParameter("nameId"));
            String mode = request.getParameter("mode");
            if (mode != null && mode.equals("deleteTab2")) {
                String sId = request.getParameter("sId");
                if (sId != null && sId != "") {
                    partnerSiteService.deletePartnerSite(Integer.parseInt(sId));
                }
            }
        }

        //===========================
        context.put("siteId", siteId);

        List<PartnerDetail> partnerDetailList = partnerDetailService.getAllDetailByPartnerSiteID(siteId);
        context.put("partnerDetailList", partnerDetailList);

        String partnerId = request.getParameter("nameId");
        int pID = Integer.parseInt(partnerId);
        List<PartnerSite> partnerSiteList =  partnerDetailService.getAllPartnerSiteById(pID);
        context.put("partnerSiteList", partnerSiteList);

        response.setContentType("text/html;charset=utf-8");
        renderer.render("templates/admin/partnerDetail.vm", context,response.getWriter());

帮帮我..

1 个答案:

答案 0 :(得分:0)

你永远不应该在两个元素上使用相同的ID! 最好使用class代替。{1}}。 id - 属性保留给唯一的idintifiers