15-奇怪的Js文件引用问题
JS文件的内容:
/*
*/
function HaveCheck(message)
{
var a=document.all.gvAccount;
var count=0;
if(a!=null)
{
for(i=0;i<a.rows.length;i++)
{
for(j=0;j<a.rows[i].cells[0].children.length;j++)
{
var var1=a.rows[i].cells[0].children[j];
if(var1.tagName=="INPUT" )
{
if(var1.type=="checkbox")
{
if (var1.checked)
count=count+1;
}
}
}
}
}
if(count==1)
{
//window.alert(message);
if(message != null)
{
return window.confirm(message);
//window.alert("test");
//return true;
}
else
{
//window.alert("ssssnull");
return true;
}
}
else
{
window.alert("Only one can be choosing.Please try again.");
return false;
}
}
按纽与JS中事件的绑定代码:
btnEdit.Attributes.Add("onclick", "Javascript:return HaveCheck('Are you sure to edit this request?');");
按纽事件代码:
protected void btnEdit_Click(object sender, EventArgs e)
{
Response.Write("test");
}
引用JS文件的代码:
1)<script language= "Javascript" src="js/checkbox.js" type="text/javascript" ></script>
此时一切正常,当我不选任何选项或者多选(count==1)的时候,提示"Only one can be choosing.Please try again".只选一项的时候,执行了询问代码,而且也执行了Response.Write("test")这句;
2)<script language= "Javascript" src="js/checkbox.js" type="text/javascript" />
此时一半正常,当我不选任何选项或者多选(count==1)的时候,提示"Only one can be choosing.Please try again".只选一项的时候,执行了询问代码,但是没有执行Response.Write("test")这句;
COPYRIGHT©2008,HTTP://ZEROBUG.CNBLOGS.COM .ALL RIGHTS RESERVED.