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

JS遍历用户控件中的TextBox的问题...............
我的页面由好多用户控件组成,但是每个页面都包括的就是bottom.ascx了

问题是这样的,我想在botton.asxc中遍历它的父页面(aspx)中的TextBox,还有与bottom同级的用户控件中的TextBox,然后给所有的TextBox加入onkeyup


<script   language=javascript>
functioh   show()
{
      现在我需要怎么做?.................
      ........代码该怎么去写?先谢过了
}
</script>

------解决方案--------------------
var a=document.getElementsByTagName( "input ");
for(var j=0;j <a.length;j++)
{
if(a[j].type== "checkbox ")
a[j].checked=document.all.selectall.checked;
}
------解决方案--------------------
把下面的script 加在页面的最底部 </body> 之前
<script>
var inputs = document.getElementsByTagName( "input ");
for(var i = 0; i < inputs.length; i++)
{
if(inputs[i].type.toLowerCase() == "text ")
inputs[i].onKeyup = 你的定义函数
}
</script>
------解决方案--------------------
function test(){
var TextBox=document.getElementsByTagName( "input ");

for(i=0;i <TextBox.length;i++){
TextBox[i].onkeyup=function(){......}
}
}