How display radiobuttonlist selec ted on another radionbuttonlist selected

Posted by Cpatil1000 under ASP.NET on 8/27/2013 | Points: 10 | Views : 791 | Status : [Member] | Replies : 1
Hi,
I am using radiobuttonlist. I have two radiobutton . if pnlSelectLanguage radiobutton list selected value 0,1,2, then my rblNonfunDuDrySour values 1(Yes) must be show selected other display values of 0(No). How I can do using javascript..

<script src="../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#<%=rblLanguage.ClientID%>").change(function () {
SelectedLanguage();
});
});

function SelectedLanguage() {
var sSelectedValue = $("input:radio[name='rblLanguage']:checked").val();
//alert('You have selected ' + sSelectedValue);
alert(rblNonfunDuDrySour.Items[1])
if (sSelectedValue == 1) {
rblNonfunDuDrySour.Items[1].checked = true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<h2>Call JavaScript function for RadioButtonList OnChange Event in jQuery?</h2>
<asp:Panel ID="pnlSelectLanguage" runat="server" GroupingText="Select Language" Width="200px">
<asp:RadioButtonList ID="rblLanguage" runat="server" AutoPostBack="false" RepeatDirection="Horizontal">
<asp:ListItem Text="C#" Value="0" ></asp:ListItem>
<asp:ListItem Text="C++" Value="1" ></asp:ListItem>
<asp:ListItem Text="Java" Value="2" ></asp:ListItem>
</asp:RadioButtonList>

<asp:RadioButtonList ID="rblNonfunDuDrySour" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1" Text="Yes" Selected="True"></asp:ListItem>
<asp:ListItem Value="0" Text="No"></asp:ListItem>
</asp:RadioButtonList>
</asp:Panel>
</center>

</div>




Responses

Posted by: kgovindarao523-21772 on: 9/5/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

I did not understand the requirement,
but small changes to your code tells that if select 0 or 2 ,your answer shows 'Yes'. otherwise 'No'.

$(document).ready(function ()
{
$("#<%=rblLanguage.ClientID%>").change(function ()
{
SelectedLanguage();
});
});

function SelectedLanguage()
{
var sSelectedValue = $("input:radio[name='rblLanguage']:checked").val();
var rblNonfunDuDrySour = $("input:radio[name='rblNonfunDuDrySour']");
alert(sSelectedValue);
if (sSelectedValue == 1)
{
$("input:radio[id='rblNonfunDuDrySour_1']").attr("checked","checked");
}
else
{
$("input:radio[id='rblNonfunDuDrySour_0']").attr("checked", "checked");
}
}

Thank you.

Thank you,
Govind

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response