在网格中设置复选框. [英] set checkbox in Grid.

查看:80
本文介绍了在网格中设置复选框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的网页上有一个网格.根据网格行有一些复选框.我想设置标题复选框,在其中单击标题复选框时,网格行中的所有其他复选框都会自动被选择为true,与取消选中标题复选框时相同,所有其他复选框都将通过Java Script取消选中.

所以,请告诉我这件事是怎么做的?
我使用在gridview中归档的模板.

谢谢和问候....
Mitesh

hello to all,

i have a grid on my web page. there are some checkbox according to grid row. i want to set header checkbox in which when i clicked on header checkbox all other checkbox which are in grid row are selected true by automatically and same as when i deselect the header checkbox, all other checkbox are deselect By java Script.

so, please tell me how this thing is done ?
i use the template filed in gridview.

Thanks and Regards ....
Mitesh

推荐答案

使用此js函数将解决您的问题.在此js中,我假设第一栏中的复选框为

use this js function it will solve your problem. in this js i assume that checkbox in first column

function SelDeSelAll(chkall,grd)
        {
            for(var rowCount=0;rowCount<grd.children[0].childNodes.length;rowCount++)
            {
                grd.children[0].childNodes[rowCount].children[0].children[0].checked=chkall.checked;
            }
        }


尝试此链接...

复选框选择/取消选择

另请参见下面的示例...

Try this link...

Checkbox select/deselect

see also below example...

<script type="text/javascript" language="javascript">
function SetAllCheckBoxes(FormName, AreaID, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.getElementById(AreaID).getElementsByTagName(''input'');
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
</script>


</head>

<div id="items">
<form name="SelectedItems" action="" method="post">
Select/Unselect All<br>
<div style="background:#ccc;"><input name="checkall" type="checkbox" onclick="SetAllCheckBoxes(''SelectedItems'',''items'',this.checked);" /></div><br><br>

<input type="checkbox" name="selected" value="Some text description 1"><input type="hidden" name="selecteditems" value=" "><br>
<input type="checkbox" name="selected" value="Some text description 2"><input type="hidden" name="selecteditems" value=" "><br>
<input type="checkbox" name="selected" value="Some text description 3"><input type="hidden" name="selecteditems" value=" "><br>
<input type="checkbox" name="selected" value="Some text description 4"><input type="hidden" name="selecteditems" value=" "><br>
<input type="checkbox" name="selected" value="Some text description 5"><input type="hidden" name="selecteditems" value=" "><br>
<input type="checkbox" name="selected" value="Some text description 6"><input type="hidden" name="selecteditems" value=" "></div>
</form>

</body>
</html>
</script>


这篇关于在网格中设置复选框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆