我必须检查复选框中的项目,然后单击添加按钮,将选中的项目添加到一个框中。检查复选框中的项目并单击添加按钮后,我得到以下错误。它仅在 IE9 中发生。
Microsoft JScript 运行时错误:无法获取“已检查”属性的值:对象为空或未定义
我的js页面代码是:
document.onkeyup = fnRemoveSelectedItems;
//Global variables
var cssGridrow="gridrow";
var cssGridalteraterow="gridalteraterow";
var selectedItems=new String();
var pickItemSelected="1";
var isOnsiteLoc = 0;
/*Function that adds the selected items to the text box in the pick up box */
function fnPickUpAdd(btnOKClientId, lstFromClientId, txtBoxClientId, ColumnToTake) {
//enable the ok button
document.getElementById(btnOKClientId).disabled=false;
//From grid Object
var lstFrom=document.getElementById(lstFromClientId);
//to textbox Object
var txtBoxObject=document.getElementById(txtBoxClientId);
//If the lstFromClienId is location then iteration occurs.
if (lstFromClientId.search(/Location/i) > 0) {
//Iterating only with in the grid rows to check if the location is onsite
for (var i = 1; i < lstFrom.rows.length; i++) {
var CheckBoxId = lstFrom.rows[i].cells[0].childNodes[0].id;
if (document.getElementById(CheckBoxId).checked && lstFrom.rows[i].cells[6].innerText != null && lstFrom.rows[i].cells[6].innerText == "True") {
isOnsiteLoc = 1;
break;
}
}
}
//Iterating only with in the grid rows to get the selected SOIDs
for(var i=0;i<lstFrom.rows.length; i++) {
if(lstFrom.rows[i].className==cssGridrow || lstFrom.rows[i].className==cssGridalteraterow) {
var childRowCheckBoxId=lstFrom.rows[i].cells[0].childNodes[0].id;
if(childRowCheckBoxId!= "") {
if(document.getElementById(childRowCheckBoxId).checked) {
//locationmatchFor = "1" for all scenarios except for location pick up in search
// so for this we would take the value in cells[1]
if(ColumnToTake=='1'){ //From Preferences
if(findMatchValue(txtBoxObject, lstFrom.rows[i].cells[1].innerText)==false) {
//show that in the text box
txtBoxObject.innerHTML+="<span onclick='fnSelectItem(this)' isItem=1>"+lstFrom.rows[i].cells[1].innerText+";</span>";
//Form this to pass the selected items to the parent page
//selectedItems+=(lstFrom.rows[i].cells[1].innerText)+":"+(lstFrom.rows[i].cells[2].innerText);
selectedItems+=(lstFrom.rows[i].cells[1].innerText);
selectedItems+=";";
}
}
}
}
}
}
}