有办法更改RadioButton 的name的值吗? 我要实现连两个RadioButtonList 中,只能选择一个RadioButton,所以我想到来更改RadioButton的name值,有办法吗?我试了好多都不行?或者还有别的方法实现吗?-------------或者在同一个RadioButtonList 中,有办法改变个别的RadioButton的字颜色吗?在线等,解决马上揭贴,分不够,再加 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <asp:RadioButtonList ID="rblUser" runat="server" AutoPostBack="True" OnSelectedIndexChanged="rblUser_SelectedIndexChanged"></asp:RadioButtonList>什么name值,不懂 只能选择一个,那为啥要用两个RadioButtonList <asp:RadioButtonList ID="rblUser1" runat="server" AutoPostBack="True"></asp:RadioButtonList><asp:RadioButtonList ID="rblUser2" runat="server" AutoPostBack="True"></asp:RadioButtonList>//绑定这两个RadioButtonList后:foreach (RadioButton button in this.rblUser1.Items) { button.GroupName= "user"; } foreach (RadioButton button in this.rblUser2.Items) { button.GroupName = "user"; }//这样就只能从这两组里面选择一项了 <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function changeradiobuttonlistname(){ var rs=document.getElementsByTagName("INPUT"); for(var i=0;i<rs.length;i++){ if(rs[i].type=="radio"){ var sour=rs[i].parentNode.innerHTML; var desc=sour.replace(/name=[^\>]+/gi,"name='newname'"); rs[i].parentNode.innerHTML=desc; alert(desc); } } } </script></head><body onload="javascript:changeradiobuttonlistname();"> <form id="form1" runat="server"> <div> <asp:RadioButtonList runat="server" ID="rbl1"> <asp:ListItem Text="11"></asp:ListItem> <asp:ListItem Text="12"></asp:ListItem> </asp:RadioButtonList> <asp:RadioButtonList runat="server" ID="rbl2"> <asp:ListItem Text="21"></asp:ListItem> <asp:ListItem Text="22"></asp:ListItem> </asp:RadioButtonList> </div> </form></body></html> 还是不能成功啊上面的大哥的弄法我感觉是可行的,不知道是不是我的改法不对,望能帮我看看----------------var rs = document.getElementById("RadioButtonList1").getElementsByTagName("INPUT"); for(i = 0;i<rs.length;i++) { if(rs[i].type=="radio"){ var sour=rs[i].parentNode.innerHTML; var desc=sour.replace("name=\"RadioButtonList1\"","name='RadioButtonList2'"); rs[i].parentNode.innerHTML=desc; window.alert(desc) } } zhjg136(天星) ( ) ---------这个大哥的不可行,因为Items的类型根本就不是RadioButton 可以了谢谢Top blackant2(乔峰) ( ) 大哥再次感谢是我弄错了的呵呵 QueryString["ReturnUrl"].ToString()系统自动添加的QueryString? 有做过仓库管理的兄弟吗? 进来帮个忙 如何从HTML字符串中提取全部的图片路径? sharepoint是什么技术 一个关于asp.net 2.0的问题 一个简单的链接问题 有哪些Sql内置的函数可以对money类型进行格式化操作呢? 从未遇到如此问题?马上结帐!朋友帮帮忙!!!! 页面访问加载速度慢 各位大侠 ASP.NET AJAX上传出错,哪位能解决。在vs2005中 asp.net窗体中TreeView的使用问题?急
<asp:RadioButtonList ID="rblUser2" runat="server" AutoPostBack="True"></asp:RadioButtonList>//绑定这两个RadioButtonList后:
foreach (RadioButton button in this.rblUser1.Items)
{
button.GroupName= "user";
}
foreach (RadioButton button in this.rblUser2.Items)
{
button.GroupName = "user";
}//这样就只能从这两组里面选择一项了
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function changeradiobuttonlistname(){
var rs=document.getElementsByTagName("INPUT");
for(var i=0;i<rs.length;i++){
if(rs[i].type=="radio"){
var sour=rs[i].parentNode.innerHTML;
var desc=sour.replace(/name=[^\>]+/gi,"name='newname'");
rs[i].parentNode.innerHTML=desc;
alert(desc);
}
}
}
</script>
</head>
<body onload="javascript:changeradiobuttonlistname();">
<form id="form1" runat="server">
<div>
<asp:RadioButtonList runat="server" ID="rbl1">
<asp:ListItem Text="11"></asp:ListItem>
<asp:ListItem Text="12"></asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList runat="server" ID="rbl2">
<asp:ListItem Text="21"></asp:ListItem>
<asp:ListItem Text="22"></asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
上面的大哥的弄法
我感觉是可行的,不知道是不是我的改法不对,望能帮我看看
----------------
var rs = document.getElementById("RadioButtonList1").getElementsByTagName("INPUT");
for(i = 0;i<rs.length;i++)
{
if(rs[i].type=="radio"){
var sour=rs[i].parentNode.innerHTML;
var desc=sour.replace("name=\"RadioButtonList1\"","name='RadioButtonList2'");
rs[i].parentNode.innerHTML=desc;
window.alert(desc)
}
}
---------
这个大哥的不可行,因为Items的类型根本就不是RadioButton
谢谢Top
blackant2(乔峰) ( )
大哥
再次感谢
是我弄错了的
呵呵