jquery how to set radio button list item based on another radio button selection asp.net c# -


i have 2 radio button lists , change text of list items in second radio button list items based on selection in first radio button list. getting selected value working, have not figured out how set individual text labels items in radio button 2. code below. much.

<script type="text/javascript">         $(document).ready(function () {             $("#<%=rb1.clientid%>").change(function () {                 var rbvalue = $("input[@name=<%=rb1.clientid%>]:radio:checked").val();                 if (rbvalue == "0") {                 <!-- need to: -->                 <!-- set rb2 list item 1 text 'sample 1' -->                 <!-- set rb2 list item 2 text 'sample 2' -->                  }                 else if (rbvalue == "1") {                 <!-- need to: -->                 <!-- set rb2 list item 1 text 'sample 3' -->                 <!-- set rb2 list item 2 text 'sample 4' -->                 }              });         });     </script>  

here sample radio buttons in code behind:

<asp:radiobuttonlist id="rb1" runat="server">     <asp:listitem value="0">option1</asp:listitem>     <asp:listitem value="1">option2</asp:listitem> </asp:radiobuttonlist> <asp:radiobuttonlist id="rb2" runat="server">     <asp:listitem value="0" text="change me 1"></asp:listitem>     <asp:listitem value="1" text="change me 2"></asp:listitem> </asp:radiobuttonlist> 

you can access radios using syntax below

$("input[@name=<%=rb2.clientid%>][value=0]") $("input[@name=<%=rb2.clientid%>][value=1]") 

just use .text set value

or

$('[id*=rb2][value=0]').text('something') $('[id*=rb2][value=1]').text('something else') 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -