code_junkie

Reading the selected value from asp:RadioButtonList using jQuery

Nov 12th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. <p><label>Do you have buffet facilities?</label>
  2. <asp:RadioButtonList ID="blnBuffetMealFacilities:chk" runat="server">
  3. <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
  4. <asp:ListItem Text="No" Value="0"></asp:ListItem>
  5. </asp:RadioButtonList></p>
  6. <div id="HasBuffet">
  7. <p><label>What is the capacity for the buffet?</label>
  8. <asp:RadioButtonList ID="radBuffetCapacity" runat="server">
  9. <asp:ListItem Text="Suitable for upto 30 guests" value="0 to 30"></asp:ListItem>
  10. <asp:ListItem Text="Suitable for upto 50 guests" value="30 to 50"></asp:ListItem>
  11. <asp:ListItem Text="Suitable for upto 75 guests" value="50 to 75"></asp:ListItem>
  12. <asp:ListItem Text="Suitable for upto 100 guests" value="75 to 100"></asp:ListItem>
  13. <asp:ListItem Text="Suitable for upto 150 guests" value="100 to 150"></asp:ListItem>
  14. <asp:ListItem Text="Suitable for upto 250 guests" value="150 to 250"></asp:ListItem>
  15. <asp:ListItem Text="Suitable for upto 400 guests" value="250 to 400"></asp:ListItem>
  16. </asp:RadioButtonList></p>
  17. </div>
  18.  
  19. $('#rblDiv input').click(function(){
  20. alert($('#rblDiv input').index(this));
  21. });
  22.  
  23. $('.divCollection div:eq(' + $('#rblDiv input').index(this) +')').show();
  24.  
  25. $('.rblClass').val();
  26.  
  27. $('#RadioButtonList1 input:checked').val()
  28.  
  29. var rblSelectedValue = $("#<%= RadioButtonList1.ClientID %> input:checked");
  30.  
  31. var deliveryService;
  32. $('.deliveryservice input').each(function () {
  33. if (this.checked) {
  34. deliveryService = this.value
  35. }
  36.  
  37. var shows_6 = function() {
  38. var selected = $("#q_7 input:radio:checked").val();
  39. if (selected == 'Groom') {
  40. $("#s_6").slideDown();
  41. } else {
  42. $("#s_6").slideUp();
  43. }
  44. };
  45. $('#q_7 input').ready(shows_6);
  46. var shows_7 = function() {
  47. var selected = $("#q_7 input:radio:checked").val();
  48. if (selected == 'Bride') {
  49. $("#s_7").slideDown();
  50. } else {
  51. $("#s_7").slideUp();
  52. }
  53. };
  54. $('#q_7 input').ready(shows_7);
  55. $(document).ready(function() {
  56. $('#q_7 input:radio').click(shows_6);
  57. $('#q_7 input:radio').click(shows_7);
  58. });
  59.  
  60. <div id="q_7" class='question '><label>Who are you?</label>
  61. <p>
  62. <label for="ctl00_ctl00_ContentMainPane_Body_ctl00_ctl00_chk_0">Bride</label>
  63. <input id="ctl00_ctl00_ContentMainPane_Body_ctl00_ctl00_chk_0" type="radio" name="ctl00$ctl00$ContentMainPane$Body$ctl00$ctl00$chk" value="Bride" />
  64. </p>
  65. <p>
  66. <label for="ctl00_ctl00_ContentMainPane_Body_ctl00_ctl00_chk_1">Groom</label>
  67. <input id="ctl00_ctl00_ContentMainPane_Body_ctl00_ctl00_chk_1" type="radio" name="ctl00$ctl00$ContentMainPane$Body$ctl00$ctl00$chk" value="Groom" />
  68. </p>
  69.  
  70. </div>
  71.  
  72. <script type="text/javascript">
  73. var mandatory_q_7 = function() {
  74. var selected = $("#q_7 input:radio:checked").val();
  75. if (selected != '') {
  76. $("#q_7").removeClass('error');
  77. }
  78. };
  79. $(document).ready(function() {
  80. $('#q_7 input:radio').click(function(){mandatory_q_7();});
  81. });
  82. </script>
  83.  
  84. <div class="section" id="s_6">
  85. <h2>Attire</h2>
  86. ...
  87. </div>
  88.  
  89. $('#<%= radBuffetCapacity.ClientID %> input').click(function (e) {
  90. var val = $('#<%= radBuffetCapacity.ClientID %>').find('input:checked').val();
  91. //Do whatever
  92. });
  93.  
  94. $('#<%= radBuffetCapacity.ClientID %>').change(function (e) {
  95. var val = $('#<%= radBuffetCapacity.ClientID %>').find('input:checked').val();
  96. //Do whatever
  97. });
  98.  
  99. <asp:RadioButtonList runat="server" ID="Intent">
  100. <asp:ListItem Value="Confirm">Yes!</asp:ListItem>
  101. <asp:ListItem Value="Postpone">Not now</asp:ListItem>
  102. <asp:ListItem Value="Decline">Never!</asp:ListItem>
  103. </asp:RadioButtonList>
  104.  
  105. $("#<%=Intent.ClientID%>").change(function(){
  106. var rbvalue = $("input[@name=<%=Intent.UniqueID%>]:radio:checked").val();
  107.  
  108. if(rbvalue == "Confirm"){
  109. alert("Woohoo, Thanks!");
  110. } else if (rbvalue == "Postpone"){
  111. alert("Well, I hope it's soon");
  112. } else if (rbvalue == "Decline"){
  113. alert("Shucks!");
  114. } else {
  115. alert("How'd you get here? Who sent you?");
  116. }
  117. });
Add Comment
Please, Sign In to add comment