javaScript动态删除行

来源:互联网 发布:程序员的数学3 pdf 编辑:程序博客网 时间:2024/06/05 08:34

function pdel(){
     var productTab=window.frames["orderdetail"].document.getElementById("orderdetailform");

//获取frame并从中通过ID获取对象
     var check=window.frames["orderdetail"].document.getElementsByName("checkbox");
     var check2=window.frames["orderdetail"].document.getElementsByName("checkbox2");
     var len=parseInt(document.getElementById("sig").value);
    

     var i=0;
     while(check.length>0 && i<check.length){
    
        if (check[i].checked==true){    
          //从下面开始处理实时改总金额 
          if (check[i].value!="" && check2[i].value!=""){
          var mon=parseInt(check[i].value);
          var totalproduct=document.getElementById("tot").innerHTML;
          if (totalproduct!=null && totalproduct!=""){
            totalproduct=parseInt(totalproduct)-mon;
            document.getElementById("tot").innerHTML=totalproduct;
          }
          var totalPrice= document.getElementById("totalPrice").value;
          if (totalPrice!=null && totalPrice!=""){
            totalPrice=parseInt(totalPrice)-mon;
            document.getElementById("totalPrice").value=totalPrice;
          }
        //从现在开始处理实时改数量
         var qua=parseInt(check2[i].value);
       // alert(qua);
          var totalq=document.getElementById("q").innerHTML;
          if (totalq!=null && totalq!=""){
            totalq=parseInt(totalq)-qua;
            document.getElementById("q").innerHTML=totalq;
          }
          }
          productTab.deleteRow(i+1);
          i=0;
        }else{
           i++;
        }
     }
  } 

原创粉丝点击