<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Handling Checkboxes, Radio Buttons and Select Options in jQuery</title>
	<atom:link href="http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/</link>
	<description>Web Development, Code Snippets, Technology, Reviews and Random Stuff Blog.</description>
	<pubDate>Tue, 07 Oct 2008 04:45:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: THE&#124;ODIN</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2871</link>
		<dc:creator>THE&#124;ODIN</dc:creator>
		<pubDate>Thu, 18 Sep 2008 15:33:36 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2871</guid>
		<description>thanks for the tips, some really usefull techniques here</description>
		<content:encoded><![CDATA[<p>thanks for the tips, some really usefull techniques here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blueonyx</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2831</link>
		<dc:creator>blueonyx</dc:creator>
		<pubDate>Sun, 03 Aug 2008 10:12:41 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2831</guid>
		<description>Thank you so much. I have a problem with radio button and it resolved by your entry ^^

Thanks again &#38; best wish for you :D</description>
		<content:encoded><![CDATA[<p>Thank you so much. I have a problem with radio button and it resolved by your entry ^^</p>
<p>Thanks again &amp; best wish for you <img src='http://jivebay.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TEA#</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2815</link>
		<dc:creator>TEA#</dc:creator>
		<pubDate>Wed, 16 Jul 2008 17:57:54 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2815</guid>
		<description>For .NET you can grab it this way, which will get an ID that END WITH your original ID, meaning .NET can prepend whatever it wants on the front and you can get your control by ID.

 $("span[id*='spnBaleTxt']")</description>
		<content:encoded><![CDATA[<p>For .NET you can grab it this way, which will get an ID that END WITH your original ID, meaning .NET can prepend whatever it wants on the front and you can get your control by ID.</p>
<p> $(&#8221;span[id*='spnBaleTxt']&#8220;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tian</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2789</link>
		<dc:creator>Tian</dc:creator>
		<pubDate>Sun, 15 Jun 2008 00:13:09 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2789</guid>
		<description>@Lacuna:  
I've found the best way to work with RadioButtons and jQuery in .NET (especially if the radiobuttons are embedded in datagrids, repeaters, etc that mangle the client ID's as per your example) is by using unique class names instead of ID's. The css class names do not have to occur in your css stylesheet (in fact, they shouldn't).
If you're already using a CSS class for your radiobutton control, then add this new unique class to the existing one. E.g. two rbn's in the same group: 



Just be aware that as another poster mentioned, .NET renders the asp:RadioButton control as a SPAN with two controls inside it: a radio input and a label. The CssClass property will be applied to the containing SPAN and NOT to the embedded Radio input control.

So you can have a jQuery click event handler like this:

$(".rbnStyle").click(function() {
  //"this" will point to the SPAN
  var rbnId = $('#'+this.firstChild.id).attr('id');
  alert("radiobutton id="+rbnId);
});

Note: .change() won't work because the ".rbnStyle" selector will actually return the SPAN elements (cos they are given the style) and they don't support a change event.</description>
		<content:encoded><![CDATA[<p>@Lacuna:<br />
I&#8217;ve found the best way to work with RadioButtons and jQuery in .NET (especially if the radiobuttons are embedded in datagrids, repeaters, etc that mangle the client ID&#8217;s as per your example) is by using unique class names instead of ID&#8217;s. The css class names do not have to occur in your css stylesheet (in fact, they shouldn&#8217;t).<br />
If you&#8217;re already using a CSS class for your radiobutton control, then add this new unique class to the existing one. E.g. two rbn&#8217;s in the same group: </p>
<p>Just be aware that as another poster mentioned, .NET renders the asp:RadioButton control as a SPAN with two controls inside it: a radio input and a label. The CssClass property will be applied to the containing SPAN and NOT to the embedded Radio input control.</p>
<p>So you can have a jQuery click event handler like this:</p>
<p>$(&#8221;.rbnStyle&#8221;).click(function() {<br />
  //&#8221;this&#8221; will point to the SPAN<br />
  var rbnId = $(&#8217;#'+this.firstChild.id).attr(&#8217;id&#8217;);<br />
  alert(&#8221;radiobutton id=&#8221;+rbnId);<br />
});</p>
<p>Note: .change() won&#8217;t work because the &#8220;.rbnStyle&#8221; selector will actually return the SPAN elements (cos they are given the style) and they don&#8217;t support a change event.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lacuna</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2787</link>
		<dc:creator>Lacuna</dc:creator>
		<pubDate>Wed, 11 Jun 2008 12:40:31 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2787</guid>
		<description>Thanks for this article however does anyone know how to do this through .net? The group name for example is unaccessible as it dynamically changes to an elongated variable at run-time.

I.E. My previously named 'LiveOptions' radio button group name will change to:
ctl00$ContentPlaceHolder1$TabContainer1$tabLiveOptions$liveDateManagementView$LiveOptions

~ Lacuna</description>
		<content:encoded><![CDATA[<p>Thanks for this article however does anyone know how to do this through .net? The group name for example is unaccessible as it dynamically changes to an elongated variable at run-time.</p>
<p>I.E. My previously named &#8216;LiveOptions&#8217; radio button group name will change to:<br />
ctl00$ContentPlaceHolder1$TabContainer1$tabLiveOptions$liveDateManagementView$LiveOptions</p>
<p>~ Lacuna</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tri'</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2769</link>
		<dc:creator>Tri'</dc:creator>
		<pubDate>Wed, 21 May 2008 10:01:25 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2769</guid>
		<description>Thanks your your entry, it very very good, it resolved my prolem.thanks you.</description>
		<content:encoded><![CDATA[<p>Thanks your your entry, it very very good, it resolved my prolem.thanks you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexandra</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2768</link>
		<dc:creator>Alexandra</dc:creator>
		<pubDate>Tue, 20 May 2008 21:24:37 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2768</guid>
		<description>Thanks a lot for the method of getting selected radio button value:

$("input[@name='option_layout']:checked").val()

:)</description>
		<content:encoded><![CDATA[<p>Thanks a lot for the method of getting selected radio button value:</p>
<p>$(&#8221;input[@name='option_layout']:checked&#8221;).val()</p>
<p> <img src='http://jivebay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flame</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2756</link>
		<dc:creator>Flame</dc:creator>
		<pubDate>Thu, 08 May 2008 04:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2756</guid>
		<description>Great reference, thanks!</description>
		<content:encoded><![CDATA[<p>Great reference, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Đỗ Nam Khánh</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2746</link>
		<dc:creator>Đỗ Nam Khánh</dc:creator>
		<pubDate>Mon, 28 Apr 2008 14:00:11 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2746</guid>
		<description>Thank you so much. I have a problem with radio button and it resolved by your entry ^^

Thanks again &#38; best wish for you :)</description>
		<content:encoded><![CDATA[<p>Thank you so much. I have a problem with radio button and it resolved by your entry ^^</p>
<p>Thanks again &amp; best wish for you <img src='http://jivebay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blogger</title>
		<link>http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2745</link>
		<dc:creator>blogger</dc:creator>
		<pubDate>Thu, 24 Apr 2008 03:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://jivebay.com/2007/05/30/handling-checkboxes-radio-buttons-and-select-options-in-jquery/#comment-2745</guid>
		<description>I got a comment from &lt;strong&gt;Jagadeesh&lt;/strong&gt; that submitted some code through my comment form asking why his dropdown select wasn't firing on the change event and he had a alert() debug in it. What I realized the switch wasn't testing for string values.

Here is code for a html page showing a dropdown select that will change divs
&lt;code&gt;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62;
&#60;head&#62;
&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62;
&#60;title&#62;Test&#60;/title&#62;
&#60;script type=&#34;text/javascript&#34; src=&#34;jquery-1.2.3.pack.js&#34;&#62;&#60;/script&#62;
&#60;script type=&#34;text/javascript&#34;&#62;
$(document).ready(function(){
	$(&#34;.propstatus_div&#34;).hide();//hide all
	$(&#34;#propStatusCd&#34;).change(function()
	{
		alert($(this).val());//debug
		$(&#34;.propstatus_div&#34;).hide();//hide all
		switch ($(this).val())
		{
			case &#039;0&#039;:
				$(&#34;#inactive&#34;).show();
			break;
			case &#039;1&#039;:
				$(&#34;#active&#34;).show();
			break;
			default:
				$(&#34;#other&#34;).show();
		}
	});
});
&#60;/script&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;form action=&#34;&#34; method=&#34;get&#34;&#62;
&#60;label&#62;Property Status
&#60;select name=&#34;propStatusCd&#34; id=&#34;propStatusCd&#34;&#62;
&#60;option&#62;Select Something&#60;/option&#62;
&#60;option value=&#34;0&#34;&#62;Inactive&#60;/option&#62;
&#60;option value=&#34;1&#34;&#62;Active&#60;/option&#62;
&#60;option value=&#34;2&#34;&#62;Suspended&#60;/option&#62;
&#60;option value=&#34;3&#34;&#62;Closed&#60;/option&#62;
&#60;option value=&#34;4&#34;&#62;Pre-Deactive&#60;/option&#62;
&#60;option value=&#34;5&#34;&#62;Deactive&#60;/option&#62;
&#60;option value=&#34;6&#34;&#62;Non-Stay&#60;/option&#62;
&#60;option value=&#34;7&#34;&#62;Test&#60;/option&#62;
&#60;option value=&#34;8&#34;&#62;Non-Starwood&#60;/option&#62;
&#60;/select&#62;
&#60;/label&#62;
&#60;/form&#62;
&#60;div id=&#34;inactive&#34; class=&#34;propstatus_div&#34; style=&#34;background:#f00;&#34;&#62;This div is #inactive&#60;/div&#62;
&#60;div id=&#34;active&#34; class=&#34;propstatus_div&#34; style=&#34;background:#0f0;&#34;&#62;This div is #active&#60;/div&#62;
&#60;div id=&#34;other&#34; class=&#34;propstatus_div&#34; style=&#34;background:#00f;&#34;&#62;This div is #other&#60;/div&#62;
&#60;/body&#62;
&#60;/html&#62;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I got a comment from <strong>Jagadeesh</strong> that submitted some code through my comment form asking why his dropdown select wasn&#8217;t firing on the change event and he had a alert() debug in it. What I realized the switch wasn&#8217;t testing for string values.</p>
<p>Here is code for a html page showing a dropdown select that will change divs<br />
<code><br />
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;<br />
&lt;title&gt;Test&lt;/title&gt;<br />
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.2.3.pack.js&quot;&gt;&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
$(document).ready(function(){<br />
	$(&quot;.propstatus_div&quot;).hide();//hide all<br />
	$(&quot;#propStatusCd&quot;).change(function()<br />
	{<br />
		alert($(this).val());//debug<br />
		$(&quot;.propstatus_div&quot;).hide();//hide all<br />
		switch ($(this).val())<br />
		{<br />
			case &#039;0&#039;:<br />
				$(&quot;#inactive&quot;).show();<br />
			break;<br />
			case &#039;1&#039;:<br />
				$(&quot;#active&quot;).show();<br />
			break;<br />
			default:<br />
				$(&quot;#other&quot;).show();<br />
		}<br />
	});<br />
});<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;form action=&quot;&quot; method=&quot;get&quot;&gt;<br />
&lt;label&gt;Property Status<br />
&lt;select name=&quot;propStatusCd&quot; id=&quot;propStatusCd&quot;&gt;<br />
&lt;option&gt;Select Something&lt;/option&gt;<br />
&lt;option value=&quot;0&quot;&gt;Inactive&lt;/option&gt;<br />
&lt;option value=&quot;1&quot;&gt;Active&lt;/option&gt;<br />
&lt;option value=&quot;2&quot;&gt;Suspended&lt;/option&gt;<br />
&lt;option value=&quot;3&quot;&gt;Closed&lt;/option&gt;<br />
&lt;option value=&quot;4&quot;&gt;Pre-Deactive&lt;/option&gt;<br />
&lt;option value=&quot;5&quot;&gt;Deactive&lt;/option&gt;<br />
&lt;option value=&quot;6&quot;&gt;Non-Stay&lt;/option&gt;<br />
&lt;option value=&quot;7&quot;&gt;Test&lt;/option&gt;<br />
&lt;option value=&quot;8&quot;&gt;Non-Starwood&lt;/option&gt;<br />
&lt;/select&gt;<br />
&lt;/label&gt;<br />
&lt;/form&gt;<br />
&lt;div id=&quot;inactive&quot; class=&quot;propstatus_div&quot; style=&quot;background:#f00;&quot;&gt;This div is #inactive&lt;/div&gt;<br />
&lt;div id=&quot;active&quot; class=&quot;propstatus_div&quot; style=&quot;background:#0f0;&quot;&gt;This div is #active&lt;/div&gt;<br />
&lt;div id=&quot;other&quot; class=&quot;propstatus_div&quot; style=&quot;background:#00f;&quot;&gt;This div is #other&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
