我想在Javascript中更改或删除asp RadioButton
GroupName。
<asp:RadioButton runat="server" ID="optbtnRight" Text="Right" GroupName="second"/>
I have this function.
function ddlColumnType_onchange(){
document.getElementById("<%=optbtnRight.ClientID %>").checked = false;
//Want set group here
}
我在
上打电话给我<asp:DropDownList ID="ddlColumnType" runat="server" class="text small"
onchange="ddlColumnType_onchange()">
</asp:DropDownList>
答案 0 :(得分:1)
首先,我建议你使用带有runat =“server”的html单选按钮而不是asp单选按钮让所有浏览器中的javascript工作没有任何问题,因为asp单选按钮在不同的浏览器中呈现不同 所以第一件事就是
替换此
<asp:RadioButton runat="server" ID="optbtnRight" Text="Right" GroupName="second"/>
有了这个
<input type="radio" runat="server" ID="optbtnRight" value="Right" name="second"/> Right
然后这应该适合你
的jQuery
$('#<%=optbtnRight.ClientID%>').attr("name","NewGroupName");
的JavaScript
document.getElementById('<%=optbtnRight.ClientID%>').setAttribute("name","NewGroupName");