To get RadioButtonList Selected values and Text on Button Click using Javascript in asp.net page (.aspx page).
See the below example:-
Write the below javascript under header section of .aspx page
<script language="javascript" type="text/javascript">
function GetSelectedItem()
{
var RB1 = document.getElementById("<%=RadioButtonList1.ClientID%>");
var radio = RB1.getElementsByTagName("input");
var label = RB1.getElementsByTagName("label");
for (var i = 0; i < radio.length; i++) {
if (radio[i].checked)
{
alert("SelectedText = " + label[i].innerHTML);
alert("SelectedValue = " + radio[i].value);
}
}
return false;
}
</script>
Call the above javascript function in asp button, to get selected radiobuttonlist Text,value:
<asp:Button ID="btnSubmit" Text="Submit" runat="server" CausesValidation="true"
ValidationGroup="General" OnClientClick="return GetSelectedItem();" />
Hope this is help full
No comments:
Post a Comment