如何给RadioButtonList这些加JS事件。

zkxp 2006-09-22 03:57:16
我有个是否的RadioButtonList点是后旁边出现输入框输入内容。点否隐藏。
...全文
771 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zkxp 2006-09-22
  • 打赏
  • 举报
回复
正解咯。中 thanks
冰宇枫 2006-09-22
  • 打赏
  • 举报
回复
<script language="javascript" type="text/javascript">
function SetVisible()
{
var txt = document.getElementById("TextBox1");
var rbl = document.getElementsByName("RadioButtonList1");
for(var i =1;i<rbl.length;i++)
{
if(rbl[i].checked && rbl[i].value=="1")
{
txt.style.visibility = "visible";
}
if(rbl[i].checked && rbl[i].value=="0")
{
txt.style.visibility = "hidden";
}
}
}
</script>


<asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick="SetVisible()" RepeatDirection="Horizontal">
<asp:ListItem Value="1">是</asp:ListItem>
<asp:ListItem Value="0">否</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
zkxp 2006-09-22
  • 打赏
  • 举报
回复
thank u RadioButtonList有个BUG就是不能把脚本加到项上,看输出。以前貌似看到过有个什么解决办法的。

CS:
c31.Attributes.Add("onClick", "tell1(this)");
c31.Items[1].Attributes.Add("onClick", "tell(this)");

THML:
<span id="c31" onClick="tell1(this)"><input id="c31_0" type="radio" name="c31" value="好" checked="checked" /><label for="c31_0">好</label><input id="c31_1" type="radio" name="c31" value="较好" /><label for="c31_1">较好</label><input id="c31_2" type="radio" name="c31" value="一般" /><label for="c31_2">一般</label><input id="c31_3" type="radio" name="c31" value="差" /><label for="c31_3">差</label></span>
jc15271149 2006-09-22
  • 打赏
  • 举报
回复
RadioButtonList1.Items[0].Attributes.Add("onclick","document.getElementById('TextBox1').style.display='none'");
RadioButtonList1.Items[1].Attributes.Add("onclick", "document.getElementById('TextBox1').style.display=''");
zkxp 2006-09-22
  • 打赏
  • 举报
回复
是用JS啊。但他生成的HTML是xx_0,xx_1这样的ID.ONCLICK事件放在了外围的SPAN标签上了。就不知道怎么写了。
foyuan 2006-09-22
  • 打赏
  • 举报
回复
用javascript
给RadioButtonList加上onclick事件

你说得太含糊 所以没办法给你写代码

62,254

社区成员

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

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

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

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