欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JQuery使用$.ajax和checkbox實(shí)現(xiàn)下次不在通知功能

 更新時(shí)間:2015年04月16日 08:54:36   投稿:junjie  
這篇文章主要介紹了JQuery使用$.ajax和checkbox實(shí)現(xiàn)下次不在通知功能,本文給出HTML代碼、JS代碼、和后端JAVA代碼完整示例,需要的朋友可以參考下

XXX平臺(tái)要實(shí)現(xiàn)一個(gè)功能,公告彈出頁(yè)面上使用復(fù)選框設(shè)置不再通知此類公告。
 
原理:<input type="checkbox" id="isSelect" name="isSelect" value="10" onclick="javascript:noTips();"/>,checkbox選中后提交表單,那么struts2的Action中isSelect就為'10',不選中提交表單isSelect為null。
 
1.jsp頁(yè)面

<form id="form1"> 
<div class="jf_tanchu"> 
  <div class="jf_tanchutit">${ bussinessNotice.noticeTitle}</div> 
  <div class="jf_tanchubox"> 
    <div class="jf_tanchubox_right"> 
    公告類型:<v:dcolor code="${ bussinessNotice.noticeType}"/>&nbsp;&nbsp;&nbsp;&nbsp; 
    發(fā)布時(shí)間:<fmt:formatDate value="${ bussinessNotice.createDate}" pattern="yyyy-MM-dd"/> 
    </div> 
    ${bussinessNotice.noticeInfo} 
  </div> 
</div> 
<s:if test="bussinessNotice.noticeType=='25'||bussinessNotice.noticeType=='63'||bussinessNotice.noticeType=='64'"> 
<div> 
  <input type="hidden" name="noticeType" value="${bussinessNotice.noticeType}"/> 
  <input type="checkbox" id="isSelect" name="isSelect" value="${bussinessNotice.noticeType}" onclick="javascript:noTips();"/> 
  <label for="isSelect">不再通知此類公告</label> 
</div> 
</s:if> 
</form> 

 2.js代碼

 function noTips(){ 
  var formParam = $("#form1").serialize();//序列化表格內(nèi)容為字符串 
  $.ajax({ 
    type:'post',   
    url:'Notice_noTipsNotice', 
    data:formParam, 
    cache:false, 
    dataType:'json', 
    success:function(data){ 
    } 
  }); 
} 
 

 3.NoticeAction代碼

/** 
 * checkbox不提示公告,需要修改TBussinessSet中的屏蔽狀態(tài),ajax異步請(qǐng)求 
 */ 
public void noTipsNotice(){ 
  try { 
    PrintWriter out = this.getResponse().getWriter(); 
     
    bussinessSet = BussinessSetService.queryById(getUserId()); 
    String state = ""; 
    if(isSelect==null){//noticeType==null沒(méi)有選中checkbox 
      state = "11"; 
    } 
    else{ 
      state = "10"; 
    } 
    if("25".equals(noticeType)){ 
      bussinessSet.setSaleBack(state); 
    } 
    else if("63".equals(noticeType)){ 
      bussinessSet.setRemittanceBank(state); 
    } 
    else if("64".equals(noticeType)){ 
      bussinessSet.setRemittanceOnline(state); 
    } 
    BussinessSetService.update(bussinessSet); 
     
    out.print(""); 
  } catch (Exception e) { 
    log.error(e.fillInStackTrace()); 
  } 
} 

相關(guān)文章

最新評(píng)論