日期:2014-05-20  浏览次数:20404 次

vs2003对javascript中getElementsByName方法的支持?
<script   language= "javascript ">
function   cheekde()
{
var   list=document.getElementsByName( 'checkboxSort ');
alert(list.length);

}
</script>
<INPUT   id= "Checkbox1 "   type= "checkbox "   value= "1 "   name= "checkboxSort "   runat= "server "> 1  
<INPUT   id= "Checkbox6 "   type= "checkbox "   value= "2 "   name= "checkboxSort "   runat= "server "> 2   <INPUT   id= "Checkbox7 "   type= "checkbox "   value= "3 "   name= "checkboxSort "   runat= "server "> 3 <INPUT   id= "Checkbox12 "   type= "checkbox "   value= "4 "   name= "checkboxSort "   runat= "server "> 4   <INPUT   id= "Checkbox13 "   type= "checkbox "   value= "5 "   name= "checkboxSort "   runat= "server "> 5  
<INPUT   id= "Button1 "   type= "button "   value= "Button "   name= "Button1 "   onclick= "return   cheekde() ">

------解决方案--------------------
以下控件是不是别的控件的子控件? 你看看生成的html代码就知道了
------解决方案--------------------
function Checkbox1_onclick() {
var checks=document.getElementsByTagName( "input ");
//alert(checks.length);
var i=0;
for(var i=0;i <checks.length;i++)
{
if(checks[i].name== 'checkboxSort ')
{
i++;
}
}
alert( "共有 "+i "个控件 ");
}
------解决方案--------------------
服务器控件的id和name都不是客户端的id和name,不要搞混。客户端id和name分别是 ClientID 和 UniqueID 属性来输出的。