日期:2014-05-16  浏览次数:20442 次

js eval方法
作者:zccst

1,实时求和

var idNumStr = $("#final_failPart_ids").val();
var idNumArr = idNumStr.split(';');
var param = "";
for(var i = 0; i < idNumArr.length; i++){
    var subArr = idNumArr[i].split(',');
    var id  = subArr[0];
    var num = subArr[1];
 
    var ok  = $("#ok_num_"+id).val();
    var bad = $("#bad_num_"+id).val();
    var more = $("#more_"+id).val();
                             
    var tmpNum = eval(ok) + eval(bad);
    alert("ok="+ok+" bad="+bad+" num="+num+" tmpNum="+tmpNum+" more="+more);
                             
     if(num == tmpNum){
              param += id + ',' + ok + ',' + bad + ',' + more + ";";
      }else{
              alert("您填写的配件数量与报修时的数量不一致!");
              return false;
      }
}