posts - 104,  comments - 34,  trackbacks - 0
<script type="text/javascript">
  function editcar() {
   var carId="";
   var checknum=0; 
   var s=document.getElementsByTagName("input");
   for (var i=0;i<s.length;i++) {
    if (s[i].getAttribute("name")=="checkbox")
     if (s[i].checked){
      checknum++;
      carId+=s[i].value;
     }
   }
   if (checknum!=1) {
    alert("请选择一辆需要修改的车辆!");
    return false; 
   }
   location.href="<%=basePath%>car.do?method=editCar&carid="+carId;
  }
  
  function delsome() {
    if(confirm("你确定要删除所选车辆信息吗?")){
    var choice="";
    var s=document.getElementsByTagName("input");
    for (var i=0;i<s.length;i++) {
     if (s[i].getAttribute("name")=="checkbox")
     if (s[i].checked)
      choice+=s[i].value+",";
    }
    if (choice)
     location.href="<%=basePath%>car.do?method=delCar&carId="+choice;
    else
     alert("请选择需要删除的车辆!")
   }
  }
 </script>


标签代码:
<input name="checkbox" type="checkbox" id="checkbox" value="${car.carId }">


删除部分的Action代码:
    public ActionForward delCar(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
     String carId = request.getParameter("carId");
        carService.delCar(carId);
        return query(mapping,form,request,response);
    }

service部分代码:
    public void delCar(String carId) {
        String arryId[] = carId.split(",");
        for (int i = 0; i < arryId.length; i++) {
            // SrcmCar car = new SrcmCar();
            // car.setCarId(arryId[i]);
            // this.getHibernateTemplate().delete(car);
            String hql = "delete from SrcmCar where carId='" + arryId[i] + "'";
            Query query = this.getSession().createQuery(hql);
            query.executeUpdate();
        }
    }
posted on 2007-10-29 12:10 末日风情 阅读(3408) 评论(0)  编辑  收藏 所属分类: javascript

只有注册用户登录后才能发表评论。


网站导航:
 
<2007年10月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿(4)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜