2010-11-20 159 views
0

我不得不做出一個代碼jQuery中的動態頁面添加組件jQuery的不工作在IE 8

var counter = 1; 
var delCnt = 0; 
$(function() { 
    $('#linkAddLot').click(function() { 
     counter = eval(document.getElementById("hdnTotLot").value); 
     delCnt = eval(document.getElementById("hdnDelLot").value); 
     if((eval(counter-delCnt))>=5){ 
      $('span.#lotMsg').css("visibility","visible"); 
      $('span.#lotMsg').css("color","red"); 
      $('span.#lotMsg').html('Already 5 (Five) Lot!!!'); 
     } else { 
      $('span.#lotMsg').css("visibility","collapse"); 
      var htmlEle = "<tr id='trLot_"+ (counter+1) +"'>"+ 
       "<td class='t-align-center'><input type='checkbox' name='packagedetail_"+ (counter+1) +"' id='chkPackageDetail_"+ (counter+1) +"' value='"+ (counter+1) +"'/></td>"+ 
       "<td class='t-align-center'><input name='lotno_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtLotNo_"+ (counter+1) +"' style='width:80px;' onBlur='chkLotNoBlank(this);chkLotNo(this);'/><span id='msgLotNo_"+ (counter+1) +"' style='color: red; ' >&nbsp;</span></td>"+ 
       "<td class='t-align-center'><textarea name='lotdesc_"+ (counter+1) +"' cols='20' rows='3' class='formTxtBox_1' id='txtLotDesc_"+ (counter+1) +"' style='width:250px;' onBlur='chkLotDetBlank(this);'></textarea><span id='msgLotDesc_"+ (counter+1) +"' style='color: red; '>&nbsp;</span></td>"+ 
       "<td class='t-align-center'><input name='quantity_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtQuantity_"+ (counter+1) +"' style='width:80px;' onBlur='chkQtyBlank(this);'/><span id='msgLotQty_"+ (counter+1) +"' style='color: red; '>&nbsp;</span></td>"+ 
       "<td class='t-align-center'><input name='unit_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtUnit_"+ (counter+1) +"' style='width:80px;' onBlur='chkUnitBlank(this);'/><span id='msgLotUnit_"+ (counter+1) +"' style='color: red; '>&nbsp;</span></td>"+ 
       "<td class='t-align-center'><input name='estimatecost_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtEstimateCost_"+ (counter+1) +"' style='width:80px;' onChange='setPkgEstCost(this);' onBlur='chkEstBlank(this);'/><span id='msgLotCost_"+ (counter+1) +"' style='color: red; '>&nbsp;</span></td>"+ 
       "</tr>"; 
      $("#tblLots").append(htmlEle); 
      document.getElementById("hdnTotLot").value = (counter+1); 
     } 
    }); 
}); 

這裏我有txtLotNo但在IE8的斜面工作取得的onblur功能上onBlur='chkLotNoBlank(this);chkLotNo(this);'

如果我將在IE 7和Firefox中運行它我工作得很好,如果我將在Windows 7中工作預安裝IE8版本IE8.0.7600.16385,但它不能工作,如果我將嘗試在Windows 2003兼容的IE 8.0.6001.18702 ,所以任何人都可以爲我解決這個問題嗎?

+0

是什麼的代碼函數'chkLotNoBlank'和'chkLotNo'?我沒有看到上面發佈的那些。 – PleaseStand 2010-11-20 07:20:19

回答

0

我不能確切地說這個問題是什麼 - 但使用這些evals絕對是時髦的。如果不需要,最好不要使用eval,它會消耗大量資源。

試試這個:

var counter = 1; 
var delCnt = 0; 

$(function() { 
    $('#linkAddLot').click(function() { 
     counter = parseInt($("#hdnTotLot").val(),10); 
     delCnt = parseInt($("#hdnDelLot").val(),10); 
     if(((counter-delCnt)>=5){ 
      $('span.#lotMsg').css("visibility","visible"); 
      $('span.#lotMsg').css("color","red"); 
      $('span.#lotMsg').html('Already 5 (Five) Lot!!!'); 
     } else { 
      $('span.#lotMsg').css("visibility","collapse"); 
      var htmlEle = ""+ ""+ " "+ " "+ " "+ " "+ " "+ ""; 
      $("#tblLots").append(htmlEle); 
      $("#hdnTotLot").val(counter+1); 
     } 
    }); 
}); 
+0

感謝您的建議和指導,但我真的感謝你,如果你會找到我的實際問題的解決方案。 – Sanju 2010-11-20 07:36:50

+0

我需要實際的代碼來分配模糊事件處理程序和模糊處理程序本身,以爲您提供可能的解決方案。 – 2010-11-20 08:28:49

+0

我要檢查其空白或不模糊事件... – Sanju 2010-11-20 08:31:56

-1

您有以下代碼:

$('span.#lotMsg').css("visibility","visible"); 
$('span.#lotMsg').css("color","red"); 
$('span.#lotMsg').html('Already 5 (Five) Lot!!!'); 

豈不是更好shortern這:

$('span.#lotMsg').css("visibility","visible").css("color","red").html('Already 5 (Five) Lot!!!'); 
+1

但這並沒有解決實際問題。這種建議更適合作爲對問題的評論。 – 2011-11-25 08:18:15