请高手帮助,我在asp.net的设计界面写了javascript,可调用时“缺少对象”
<script language="javascript">
<!--
function SelectAllCheckboxes(spanChk){
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox=oItem.item(0);
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
{
//elm[i].click();
if(elm[i].checked!=xState)
elm[i].click();
//elm[i].checked=xState;
}
}
function HighlightRow(chkB) {
var oItem = chkB.children;
xState=oItem.item(0).checked;
if(xState)
{chkB.parentElement.parentElement.style.backgroundColor='lightcoral';
chkB.parentElement.parentElement.style.color='white'; }else
{chkB.parentElement.parentElement.style.backgroundColor='white';
chkB.parentElement.parentElement.style.color='black'; }
}
function ForceError(msg, url, lno) {
alert("Error Occurred!Handled by Generic Error Handler" + "\n" +
"Error:" + msg + "\n" + "URL:" + url + "\n" +
"Line Number:" + lno);
return true;
}
window.onerror = ForceError;
// -->
</script>
我在界面中调用:
<asp:CheckBox name="chkAll" id="chkAll" onclick=" javascript:SelectAllCheckboxes(this);" runat="server" AutoPostBack=False
ToolTip="Select/Deselect All"></asp:CheckBox>
<INPUT onclick="javascript:SelectAllCheckboxes(this);" type="checkbox" id="dd">
为什么会“缺少对象”