当前位置: 代码迷 >> JavaScript >> 怎么全选列表框里的数据呀
  详细解决方案

怎么全选列表框里的数据呀

热度:313   发布时间:2012-02-06 15:52:44.0
如何全选列表框里的数据呀?
点击全选按钮的时候,如何全选多选列表框里的数据呀?

------解决方案--------------------
<html>
<head> <title> </title> </head>
<body>
<script type= 'text/javascript '>
function checkall(cb,f)
{
for(var i=0;i <f.elements.length;i++)
{
var e=f.elements[i];
if (e.name!=cb.name)
e.checked=cb.checked;
}
}
</script>
<form name= 'form1 '>
<input type= 'checkbox ' name= 'chkall ' onclick= 'checkall(this,this.form) '/> 全部选择 <br/>
<input type= 'checkbox ' /> 1 <br/>
<input type= 'checkbox ' /> 2 <br/>
<input type= 'checkbox ' /> 3 <br/>
<input type= 'checkbox ' /> 4 <br/>
<input type= 'checkbox '/> 5 <br/>
<input type= 'checkbox ' /> 6 <br/>
</form>
</body>
</html>


这个效果??
  相关解决方案