两个 RadioButtonList

hailiu123 2010-03-20 02:44:17
有两个radiobuttonlist ,怎样让他们使用起来就像一个radiobuttonlist
...全文
128 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangsiya_xiaoshan 2011-05-25
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 koukoujiayi 的回复:]
html代码:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick="test('2')">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioBut……
[/Quote]
这个确实能实现,但是如果我有4个radiobuttonlist该怎么办呢?谢谢
koukoujiayi 2010-03-20
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 hailiu123 的回复:]
追加分,大家帮帮忙
[/Quote]
追加分很好哦!不过4楼给你的代码难道不行吗?
如果不行?哪里不行???
lrforever1 2010-03-20
  • 打赏
  • 举报
回复
不知道你是不是这个意思,
<asp:RadioButtonList ID="RadioButtonList1" runat="server" ValidationGroup="0">
<asp:ListItem Text="123123" />
<asp:ListItem Text="123123" />
<asp:ListItem Text="123123" />
</asp:RadioButtonList>
<asp:RadioButtonList ID="RadioButtonList2" runat="server" ValidationGroup="0" >
<asp:ListItem Text="123123" />
<asp:ListItem Text="123123" />
<asp:ListItem Text="123123" />
</asp:RadioButtonList>


设置同样的组应该就可以实现的想要的效果
wuyq11 2010-03-20
  • 打赏
  • 举报
回复
protected void RadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
RadioButtonList rdbl=sender as RadioButtonList;
if (rdbl.SelectedIndex != -1)
{

}
RadioButtonList1.ClearSelection();
}

hailiu123 2010-03-20
  • 打赏
  • 举报
回复
追加分,大家帮帮忙
hailiu123 2010-03-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 liuyileneal 的回复:]
可以啊,把事件里的代码写一样就行了
[/Quote] 再说清楚点,就是如果第一个radiobuttonlist有一个项被选中了,你在选中第二个radiobuttonlist的项时候,第一个中的被选中的项就取消了,如果你重新在第一个radioButtonlist选中一项,第二个radiobuttonlist被选中的项就取消了。。。。
两个 radiobuttonlist 都有多个子项的
最好写些代码然我看看
koukoujiayi 2010-03-20
  • 打赏
  • 举报
回复
html代码:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick="test('2')">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="RadioButtonList2" runat="server" onclick="test('1')">
<asp:ListItem>c</asp:ListItem>
<asp:ListItem>d</asp:ListItem>
<asp:ListItem>e</asp:ListItem>
</asp:RadioButtonList>

js代码:
<script type="text/javascript">
function test(n) {
var a = document.getElementById("RadioButtonList"+n).cells.length;
var b = "RadioButtonList"+n+"_";
for (var i =0 ; i < a; i++) {
bb=b +i;
document.getElementById(bb).checked=false;
}
}
</script>
liuyileneal 2010-03-20
  • 打赏
  • 举报
回复
可以啊,把事件里的代码写一样就行了
hailiu123 2010-03-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 liuyileneal 的回复:]
在不同的条件下显示对应的那个,将不满足条件的隐藏,把每个控件slectchanged事件给实现了
[/Quote]我没说清楚,我的两个radiobuttonlist同时显示,只是这两个所在的位置不同,但是实现的功能和一个radiobuttonlist一样,
liuyileneal 2010-03-20
  • 打赏
  • 举报
回复
在不同的条件下显示对应的那个,将不满足条件的隐藏,把每个控件slectchanged事件给实现了

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧