Search

just show me the code

Monday, March 2, 2009

RadioButtonList jQuery get and set


    8     <script src="http://www.google.com/jsapi"></script>  
    9     <script type="text/javascript">  
   10
   11         // Load jQuery
   12         google.load("jquery", "1.3.2");
   13         google.load("jqueryui", "1.7.1");
   14         google.load("yui", "2.7.0");
   15
   16         google.setOnLoadCallback(function() {  
   17             // Your code goes here.  
   18         });  
   19     </script> 


here is the page aspx

  
    4 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 
    5     <script language="javascript">
    6         $(document).ready(function() {
    7             $('#rblDiv input').click(function() {
    8                 var selected = $("#rblDiv input:radio:checked").val();
    9                 $("#output").text(selected);
   10             });
   11             $("#btnChangeValue").click(function() {
   12                 $('#<%=RadioButtonList1.ClientID %>').find("input[value='Three']").attr("checked", "checked");
   13                 $('#rblDiv input:radio:checked').trigger('click');
   14             });
   15
   16         });  
   17     </script> 
   18 </asp:Content>
   19 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   20     <div id="rblDiv">
   21         <asp:RadioButtonList ID="RadioButtonList1" runat="server">
   22             <asp:ListItem Value="One">1</asp:ListItem>
   23             <asp:ListItem Value="Two">2</asp:ListItem>
   24             <asp:ListItem Value="Three">3</asp:ListItem>
   25         </asp:RadioButtonList>
   26     </div>
   27     <input id="btnChangeValue" type="button" value="Change to Three" />
   28     <div id="output"></div>
   29 </asp:Content>






for the checkboxlist check out this and this post

No comments:

Post a Comment

Contributors