会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
优雅旋律
看破红尘七情是,醉梦舒身落雪终
博客园
首页
新随笔
联系
订阅
管理
checkboxlist实现单选
function
CheckBoxList_Click(sender)
{
var
container
=
sender.parentNode;
if
(container.tagName.toUpperCase()
==
"
TD
"
)
{
//
服务器控件设置呈现为 table 布局(默认设置),否则使用流布局
container
=
container.parentNode.parentNode;
//
层次: <table><tr><td><input />
}
var
chkList
=
container.getElementsByTagName(
"
input
"
);
var
senderState
=
sender.checked;
for
(
var
i
=
0
; i
<
chkList.length;i
++
)
{
chkList[i].checked
=
false
;
}
sender.checked
=
senderState;
}
<
h3
>
单选效果的 CheckBoxList
</
h3
>
<
div
style
="float:left"
>
<
h4
>
静态项
</
h4
>
<
asp:CheckBoxList
ID
="CheckBoxList1"
BorderWidth
="1"
runat
="server"
RepeatLayout
="Flow"
>
<
asp:ListItem
onclick
="CheckBoxList_Click(this)"
Value
="Item1"
>
Item1
</
asp:ListItem
>
<
asp:ListItem
onclick
="CheckBoxList_Click(this)"
Value
="Item2"
>
Item2
</
asp:ListItem
>
<
asp:ListItem
onclick
="CheckBoxList_Click(this)"
Value
="Item3"
>
Item3
</
asp:ListItem
>
<
asp:ListItem
onclick
="CheckBoxList_Click(this)"
Value
="Item4"
>
Item4
</
asp:ListItem
>
<
asp:ListItem
onclick
="CheckBoxList_Click(this)"
Value
="Item5"
>
Item5
</
asp:ListItem
>
</
asp:CheckBoxList
>
</
div
>
<
div
style
="float:left;padding-left:100px"
>
<
h4
>
绑定项
</
h4
>
<
asp:CheckBoxList
ID
="CheckBoxList2"
BorderWidth
="1"
runat
="server"
DataTextField
="Value"
DataValueField
="Key"
OnDataBound
="CheckBoxList2_DataBound"
>
</
asp:CheckBoxList
>
</
div
>
posted on
2007-11-15 15:01
优雅旋律
阅读(
865
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部