2010-07-20 84 views
0

我有一個名爲chkboxContact的複選框服務器控件。在檢查IAM填充賈森數據到文本框在Firefox其工作正常,但不是在IE.Please推薦.Thanks

<script type="text/javascript"> 
function GetInfo() { 

    var checkboxInfo = $('#ctl00_PlaceHolderCenter1_chkboxContact'); 
    var domcheckboxInfo = checkboxInfo[0]; 
    if (domcheckboxInfo.checked == true) { 


    GetUserInfo(); 

    } 
    else { 
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxContactperson").value = ""; 
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxMobileNo").value = ""; 
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxEmailId").value = ""; 
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxTelephone").value = ""; 
     } 
} 

function GetUserInfo() { 

     $.ajax({ 
      type: "POST", 
      contentType: "application/json; charset=utf-8", 
      url: "../ProfileService.asmx/GetUserInfo", 
          async: false, 
      data: "{ }", // send an empty object for calls with no parameters 
      dataType: "json", 
      success: displayUserInfo, 
      failure: reportError 
      }); 



    } 


function displayUserInfo(response) { 

var firstname; 
var MobileNo; 
var EmailId; 
var PhoneNo; 
var str = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; 
for (var i = 0; i < str.length; i++) { 
    document.getElementById("ctl00_PlaceHolderCenter1_txtboxContactperson").value = str[i].FirstName; 
    document.getElementById("ctl00_PlaceHolderCenter1_txtboxMobileNo").value = str[i].MobileNo; 
    document.getElementById("ctl00_PlaceHolderCenter1_txtboxEmailId").value = str[i].EmailId; 
    document.getElementById("ctl00_PlaceHolderCenter1_txtboxTelephone").value = str[i].PhoneNo; 

} 



} 

function reportError(XMLHttpRequest, textStatus, errorThrown) { 
alert("Status: " + textStatus); alert("Error: " + errorThrown); 
} 



</script> 
+0

請將您的代碼格式化爲代碼塊,以便我們可以正確讀取它。 – 2010-07-20 14:18:13

+0

瞭解更多有關錯誤的信息也很有趣。瀏覽器錯誤?服務器錯誤?什麼都沒發生?發生了什麼錯誤? – Pointy 2010-07-20 14:21:38

+0

1.你的代碼在哪裏失敗? 2.你的控件有一堆服務器生成的ID。如果可能,您應該動態地將它們添加到腳本中。 – 2010-07-20 15:02:13

回答

相關問題