RadiobuttonList set and get values javascript
For getting values from radiobuttton list
<asp:RadioButtonList ID="radiolist" runat="server" onclick="GetRadioButtonListSelectedValue(this);">
<asp:ListItem Value="witharn" Selected="True"><b>With EUIN & distributor code</b></asp:ListItem>
<asp:ListItem Value="Withoutarn"><b>Without distributor code</b></asp:ListItem>
</asp:RadioButtonList>
and script is
function GetRadioButtonListSelectedValue(radioButtonList) {
for (var i = 0; i < radioButtonList.rows.length; ++i) {
if (radioButtonList.rows[i].cells[0].firstChild.checked) {
var chk = radioButtonList.rows[i].cells[0].firstChild.value;
if (chk == 'witharn') {
$("#<%=paneldist.ClientID%>").css("display", "block");
}
else {
$("#<%=paneldist.ClientID%>").css("display", "none");
}
}
}
}
for setting values
$("#ctl00_master_Content_rbtnlist1").find("input[value='" + abc + "']").attr("checked", "checked");
<asp:RadioButtonList ID="radiolist" runat="server" onclick="GetRadioButtonListSelectedValue(this);">
<asp:ListItem Value="witharn" Selected="True"><b>With EUIN & distributor code</b></asp:ListItem>
<asp:ListItem Value="Withoutarn"><b>Without distributor code</b></asp:ListItem>
</asp:RadioButtonList>
and script is
function GetRadioButtonListSelectedValue(radioButtonList) {
for (var i = 0; i < radioButtonList.rows.length; ++i) {
if (radioButtonList.rows[i].cells[0].firstChild.checked) {
var chk = radioButtonList.rows[i].cells[0].firstChild.value;
if (chk == 'witharn') {
$("#<%=paneldist.ClientID%>").css("display", "block");
}
else {
$("#<%=paneldist.ClientID%>").css("display", "none");
}
}
}
}
for setting values
$("#ctl00_master_Content_rbtnlist1").find("input[value='" + abc + "']").attr("checked", "checked");
Comments