RadioButtonList change event in jquery

Trap RedioButtonList change event in Jqury OR RadioButtonList selected value in Jquery:

<asp:RadioButtonList ID="rblBannerType" ClientIDMode="Static" runat="server" 
              RepeatDirection="Horizontal" >
    <asp:ListItem Value="image" Selected="True">Image</asp:ListItem>
    <asp:ListItem Text="html" >Html</asp:ListItem>
</asp:RadioButtonList> 

//jquery script
<script>
	$(function () {
		var t = $("#rblBannerType input:checked").val();
		SetBannerType(t);

		//Banner Type
		$("#rblBannerType").change(function () {
			var type = $("#rblBannerType input:checked").val();
			SetBannerType(type);
		});
	});
	function SetBannerType(type) {
		if (type == "image") {
			$("#divImage").show();
			$("#divHtml").hide();
		}
		else {
			$("#divHtml").show();
			$("#divImage").hide();
		}
	}
</script>
Advertisement

Posted on April 28, 2011, in Asp.Net, C# and tagged , . Bookmark the permalink. Leave a Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.