<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSSKarma &#187; advanced</title>
	<atom:link href="http://www.csskarma.com/blog/tag/advanced/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csskarma.com/blog</link>
	<description>display your &#60;style&#62;</description>
	<lastBuildDate>Sun, 11 Jul 2010 04:57:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Sliding Labels v2 &#8211; Patch</title>
		<link>http://www.csskarma.com/blog/sliding-labels-v2/</link>
		<comments>http://www.csskarma.com/blog/sliding-labels-v2/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 15:51:37 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[advanced]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.csskarma.com/blog/?p=772</guid>
		<description><![CDATA[window.location = "http://www.csskarma.com/blog/sliding-labels-plugin/" Please use version 3 of sliding labels with updated options and bug fixes at: http://www.csskarma.com/blog/sliding-labels-plugin/ Last week I wrote an article about sliding form labels that got quite a bit of attention. Many of the commenters brought up a couple good points/bug in the Sliding Label code that I wanted to address [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.csskarma.com/blog/wp-content/uploads/banner_slidinglabel2.jpg" alt="banner"></p>
<p><script>
window.location = "http://www.csskarma.com/blog/sliding-labels-plugin/"
</script></p>
<div style="background: #fffcdB; padding: 10px; margin: 0 0 30px; border: 1px solid #bebf6b; clear: both; font-size: 16px;">Please use <strong>version 3</strong> of sliding labels with updated options and bug fixes at: <a href="http://www.csskarma.com/blog/sliding-labels-plugin/">http://www.csskarma.com/blog/sliding-labels-plugin/</a></div>
<p>Last week I wrote an article about sliding form labels that got quite a bit of attention. Many of the commenters brought up a couple good points/bug in the Sliding Label code that I wanted to address and provide a patch for:</p>
<ul>
<li>The sliding label was barfing out in <strong>Safari</strong> when auto-fill was active</li>
<li>The default scripting didn&#8217;t work on <strong>textareas</strong></li>
</ul>
<p>I sat down yesterday and wrote a patch/new version of sliding labels which I think addresses these two problems.</p>
<p class="demo"><a href="http://www.csskarma.com/lab/plugin_slidinglabels/">View the Demo</a></p>
<h3>The new jQuery</h3>
<pre><code>$(function(){
$('form#info .slider label').each(function(){
	var labelColor = '#999';
	var restingPosition = '5px';

	<span>// style the label with JS for progressive enhancement</span>
	$(this).css({
		'color' : labelColor,
		 	'position' : 'absolute',
	 		'top' : '6px',
			'left' : restingPosition,
			'display' : 'inline',
    		        'z-index' : '99'
	});

	var inputval = $(this).next().val();

	<span>// grab the label width, then add 5 pixels to it</span>
	var labelwidth = $(this).width();
	var labelmove = labelwidth + 5 +'px';

	<span>// onload, check if a field is filled out, if so, move the label out of the way</span>
	if(inputval !== ''){
		$(this).stop().animate({ 'left':'-'+labelmove }, 1);
	}    	

	<span>// if the input is empty on focus move the label to the left
	// if it's empty on blur, move it back</span>
	$('input, textarea').focus(function(){
		var label = $(this).prev('label');
		var width = $(label).width();
		var adjust = width + 5 + 'px';
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':'-'+adjust }, 'fast');
		} else {
			label.css({ 'left':'-'+adjust });
		}
	}).blur(function(){
		var label = $(this).prev('label');
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':restingPosition }, 'fast');
		}	

	});
}); <span>// End "each" statement</span>
}); <span>// End loaded jQuery</span></code></pre>
<h3>Textarea HTML</h3>
<p>The HTML for the textarea follows the same convention as the rest of the inputs, in only needing a wrapping element.</p>
<pre><code>&lt;div id="comment-wrap"  class="slider"&gt;
    &lt;label for="comment"&gt;Comment&lt;/label&gt;
    &lt;textarea cols="53" rows="10" id="comment"&gt;&lt;/textarea&gt;
&lt;/div&gt;&lt;!--/#comment-wrap--&gt;</code></pre>
<p>There are no major changes to the plugin, just a few tweaks. If you find anymore bug, please let me know.</p>
<p class="demo"><a href="http://www.csskarma.com/lab/plugin_slidinglabels/">View the Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.csskarma.com/blog/sliding-labels-v2/feed/</wfw:commentRss>
		<slash:comments>115</slash:comments>
		</item>
		<item>
		<title>Form Design with Sliding Labels</title>
		<link>http://www.csskarma.com/blog/sliding-labels/</link>
		<comments>http://www.csskarma.com/blog/sliding-labels/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 19:01:56 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[advanced]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.csskarma.com/blog/?p=689</guid>
		<description><![CDATA[Please use version 3 of sliding labels with updated options and bug fixes at: http://www.csskarma.com/blog/sliding-labels-plugin/ A few weeks ago I was reading an article on form UI by Luke Wroblewski of Yahoo!. For those who aren&#8217;t familiar with Luke, he (quite literally) wrote the book on good form design. In the article, one certain section [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.csskarma.com/blog/wp-content/uploads/banner_slidinglabel.jpg" alt="Sliding Label banner"></p>
<div style="background:#fffcdB;padding:10px;margin:0 0 30px;border:1px solid #bebf6b;clear:both;font-size:16px;">Please use <strong>version 3</strong> of sliding labels with updated options and bug fixes at: <a href="http://www.csskarma.com/blog/sliding-labels-plugin/">http://www.csskarma.com/blog/sliding-labels-plugin/</a></div>
<p>A few weeks ago I was reading an <a href="http://www.lukew.com/ff/entry.asp?968">article</a> on form UI by <a href="http://www.lukew.com/">Luke Wroblewski</a> of <a href="http://www.yahoo.com/">Yahoo!</a>.  For those who aren&#8217;t familiar with Luke, he (<a href="http://rosenfeldmedia.com/books/webforms/">quite literally</a>) wrote the book on good form design.</p>
<p>In the article, one certain section about placing labels inside of form fields stood out to me:</p>
<blockquote cite="http://www.lukew.com/ff/entry.asp?968"><p>Because labels within fields need to go away when people are entering their answer into an input field, the context for the answer is gone. So if you suddenly forget what question you’re answering, tough luck—the label is nowhere to be found. As such, labels within inputs aren’t a good solution for long or even medium-length forms. When you’re done filling in the form, all the labels are gone! That makes it a bit hard to go back and check your answers. <cite>Luke Wroblewski</cite></p></blockquote>
<p>He brings up a good point. Generally speaking, you can look at a field that says &#8220;Tim Wright&#8221; and know that it was a field for your (my) name. But for long forms, yea, I do agree that you can forget some of the questions you answered.</p>
<p>For best practice, Luke talks about leaving your labels outside the form field so it&#8217;s always available to the user. I do think it&#8217;s a pretty good solution, but <strong>I think we can get a little more creative than that</strong>.</p>
<h3>Enter: Sliding Labels</h3>
<p>After reading that article it occurred to me that there&#8217;s no reason we can&#8217;t have the best of both worlds. I like how inline labels look, and I see Luke&#8217;s point about them disappearing as you fill out the form. But, we have jQuery, we know about progressive enhancement, and we have creative minds, so let&#8217;s build something that allows us to keep the label inline, but <strong>slide it off to the left</strong> (or up, whichever you prefer) rather than going away on click.</p>
<p class="demo"><a href="http://www.csskarma.com/lab/plugin_slidinglabels/">View demo (version 2)</a></p>
<h4>The HTML</h4>
<pre><code>&lt;form action="" method="post" id="info"&gt;
   &lt;h2&gt;Contact Information&lt;/h2&gt;
   &lt;div id="name-wrap" class="slider"&gt;
      &lt;label for="name"&gt;Name&lt;/label&gt;
      &lt;input type="text" id="name" name="name"&gt;
   &lt;/div&gt;<span>&lt;!--/#name-wrap--&gt;</span>

   &lt;div id="email-wrap"  class="slider"&gt;
      &lt;label for="email"&gt;E&amp;ndash;mail&lt;/label&gt;
      &lt;input type="text" id="email" name="email"&gt;
   &lt;/div&gt;<span>&lt;!--/#email-wrap--&gt;</span>

   &lt;div id="street-wrap"  class="slider"&gt;
      &lt;label for="st"&gt;Street&lt;/label&gt;
      &lt;input type="text" id="st" name="st"&gt;
   &lt;/div&gt;<span>&lt;!--/#street-wrap--&gt;</span>

   &lt;div id="city-wrap"  class="slider"&gt;
      &lt;label for="city"&gt;City &amp;amp; State&lt;/label&gt;
      &lt;input type="text" id="city" name="city"&gt;
   &lt;/div&gt;<span>&lt;!--/#city-wrap--&gt;</span>

   &lt;div id="zip-wrap"  class="slider"&gt;
      &lt;label for="zip"&gt;Zip code&lt;/label&gt;
      &lt;input type="text" id="zip" name="zip"&gt;
   &lt;/div&gt;<span>&lt;!--/#zip-wrap--&gt;</span>

   &lt;input type="submit" id="btn" name="btn" value="submit"&gt;
&lt;/form&gt;</code></pre>
<p>The only necessary items to make sliding labels (as I built it) work are the wrapper element (<code>DIV</code> in my case) and applying a class of &#8220;slider&#8221; to it (you can change this easily in the JavaScript).</p>
<p>At this point we have a pretty basic, and ugly form</p>
<p><img src="http://www.csskarma.com/blog/wp-content/uploads/slidinglabels_nocss.png" alt="slidinglabels no css" /></p>
<h4>The CSS</h4>
<pre><code>body                       { font:12px/1.3 Arial, Sans-serif; }
form                       { width:380px;padding:0 90px 20px;margin:auto;background:#f7f7f7;border:1px solid #ddd; }
div                        { clear:both;position:relative;margin:0 0 10px; }
label                      { cursor:pointer;display:block; }
input[type="text"]         { width:300px;border:1px solid #999;padding:5px;-moz-border-radius:4px; }
input[type="text"]:focus   { border-color:#777; }
input[name="zip"]          { width:150px; }

/* submit button */
input[type="submit"]       { cursor:pointer;border:1px solid #999;padding:5px;-moz-border-radius:4px;background:#eee; }
input[type="submit"]:hover,
input[type="submit"]:focus { border-color:#333;background:#ddd; }
input[type="submit"]:active{ margin-top:1px; }
</code></pre>
<p>The only 100% necessary CSS in there is the <code>position:relative</code> on the wrapper element (<code>DIV</code>). The rest is basically cosmetic and you can mess with it as you see fit.</p>
<p>At this point you should have a pretty normal looking form with labels on top of their respective inputs.</p>
<p><img src="http://www.csskarma.com/blog/wp-content/uploads/labelslider_nojs.png" alt="labelslider no js" /></p>
<h4>The jQuery</h4>
<p>Now for the section everyone skipped to, provided you didn&#8217;t go straight to the demo (which I usually do).</p>
<pre><code>$(function(){
$('form#info .slider label').each(function(){
	var labelColor = '#999';
	var restingPosition = '5px';

	<span>// style the label with JS for progressive enhancement</span>
	$(this).css({
		'color' : labelColor,
		 	'position' : 'absolute',
	 		'top' : '6px',
			'left' : restingPosition,
			'display' : 'inline',
    	               'z-index' : '99'
	});

	<span>// grab the input value</span>
	var inputval = $(this).next('input').val();

	<span>// grab the label width, then add 5 pixels to it</span>
	var labelwidth = $(this).width();
	var labelmove = labelwidth + 5;

	<span>//onload, check if a field is filled out, if so, move the label out of the way</span>
	if(inputval !== ''){
		$(this).stop().animate({ 'left':'-'+labelmove }, 1);
	}    	

	<span>// if the input is empty on focus move the label to the left</span>
	<span>// if it's empty on blur, move it back</span>
	$('input').focus(function(){
		var label = $(this).prev('label');
		var width = $(label).width();
		var adjust = width + 5;
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':'-'+adjust }, 'fast');
		} else {
			label.css({ 'left':'-'+adjust });
		}
	}).blur(function(){
		var label = $(this).prev('label');
		var value = $(this).val();
		if(value == ''){
			label.stop().animate({ 'left':restingPosition }, 'fast');
		}
	});
})
});</code></pre>
<p>At this point, you should have a fully working sliding label form!</p>
<p><img src="http://www.csskarma.com/blog/wp-content/uploads/labelslider_final.png" alt="labelslider final" /></p>
<p class="demo"><a href="http://www.csskarma.com/lab/plugin_slidinglabels/">View demo (version 2)</a></p>
<p>Making sure everything is still usable without JavaScript is important (no matter what people say), it&#8217;s just a basic principle of progressive enhancement. Believe it or not, there are still people browsing without JavaScript (blackberry users &#8211; turned off by default). So creating the interaction in layers, as we did, will help it be <strong>past-proof</strong>.</p>
<p>Try it out and let me know what you think. So far I&#8217;ve used it on a password change form, so definitely let me know if you find a place to use it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csskarma.com/blog/sliding-labels/feed/</wfw:commentRss>
		<slash:comments>140</slash:comments>
		</item>
		<item>
		<title>Conditional Animation Speed in jQuery</title>
		<link>http://www.csskarma.com/blog/conditional-animation-speed/</link>
		<comments>http://www.csskarma.com/blog/conditional-animation-speed/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 17:00:43 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[advanced]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.csskarma.com/blog/?p=694</guid>
		<description><![CDATA[For years (and by &#8220;years&#8221;, I most likely mean &#8220;the years since I started using jQuery&#8230; maybe 2&#8243;), there&#8217;s been one aspect of jQuery that&#8217;s bugged the crap out of me, the animation speed. View demo We&#8217;ve all probably seen the problem that happens in many drop down menus of varying height. We set slideDown(300) [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.csskarma.com/blog/wp-content/uploads/turtle.jpg" alt="Turtle"></p>
<p>For years (and by &#8220;years&#8221;, I most likely mean &#8220;the years since I started using jQuery&#8230; maybe 2&#8243;), there&#8217;s been one aspect of jQuery that&#8217;s bugged the crap out of me, the animation speed.</p>
<p class="demo"><a href="http://www.csskarma.com/lab/animation_speed/">View demo</a></p>
<p>We&#8217;ve all probably seen the problem that happens in many drop down menus of varying height. We set <code>slideDown(300)</code> (or whatever you set it to) on all the submenus and leave like that. Inevitably, menus grow and shrink based on the content and we get this weird and mildly annoying behavior of really fast moving tall menus vs. shorter menus that move painfully slow just because there&#8217;s not much content in there.</p>
<p>This problem stems from where we set the speed of the animation; the value isn&#8217;t actually a speed, it&#8217;s how long it takes (in milliseconds, I think) for the animation to finish. So you can see why you get varying behaviors based on the element height.</p>
<p>It&#8217;s true, that you can use the built-in speed values like &#8220;fast&#8221; and &#8220;slow&#8221;, but if you want more fine-grained control over your animation, you&#8217;ll have to use a value.</p>
<h3>Problem Child <a href="http://us.imdb.com/title/tt0100419/">&#8734;</a></h3>
<p>This is what our problem menu looks like all collapsed, just 2 clickable headings (<code>h2</code>) that will slide open to expose content (<code>p</code>)</p>
<p><img src="http://www.csskarma.com/blog/wp-content/uploads/animation_collapsed.png" alt="animation collapsed"></p>
<p>Normally our jQuery would look something like this:</p>
<pre><code>$(function(){

$('h2').toggle(function(){
    <span>/* get the next element */</span>
    var next_element = $(this).next();

    <span>/* open it  if it's closed */</span>
    next_element.slideDown(500);
},function(){
    <span>/* get the next element again */</span>
    var next_element = $(this).next();

    <span>/* close it if it's open */</span>
    next_element.slideUp(500);
});

});</code></pre>
<p>Note: just example code, I didn&#8217;t check to see if it actually works</p>
<p>This is our menu fully expanded. As you can see, the first item has a lot more content then the second. Using the code above will make menu #1 move noticeably faster than menu #2; which, to me, creates an odd user experience. Because you&#8217;re like &#8220;Why&#8217;s is moving so slow?&#8221;</p>
<p><img src="http://www.csskarma.com/blog/wp-content/uploads/animation_expanded.png" alt="animation expanded" /></p>
<p>So let&#8217;s see if we can&#8217;t fix that.</p>
<h3>Ben Healy (Solution) <a href="http://us.imdb.com/name/nm0000615/">&#8734;</a></h3>
<p>What we&#8217;re looking to do here is <strong>get the height</strong> of each collapsed item, do some JS math, and set a speed (animation time) value based on the height.</p>
<h4>jQuery functions we&#8217;ll need</h4>
<ul>
<li><a href="http://docs.jquery.com/Traversing/next">next()</a></li>
<li><a href="http://docs.jquery.com/CSS/height">height()</a></li>
<li><a href="http://docs.jquery.com/Effects/slideUp">slideDown()</a> / <a href="http://docs.jquery.com/Effects/slideDown">slideUp()</a></li>
</ul</p>
<h4>The Code</h4>
<pre><code>$(function(){

	<span>/* Variables to set */</span>
	var id = '#heightCheck';
	var click_element = 'h2';
	var height_value = '100';
	var tall_menu_speed = 400;
	var short_menu_speed = 250;

	<span>/* System variables, probably don't change */</span>
	var target = id +' '+ click_element;
	var menu_content = $(target).next();

	<span>/* Hide the element after the click_element, whether it's a
	div, p, ul, whatever you choose to wrap the items in */</span>
	menu_content.hide();

	$(target).toggle(function(){
		<span>/* save the menu items in a variable */</span>
		var this_menu = $(this).next();

		<span>/* get the menu height and save it */</span>
		var menu_height = this_menu.height();

		<span>/* Calculate the animation speed based on the element height */
		/* if the height is greater than the height set above use the
		tall menu height */</span>
		if(menu_height > height_value){
			var speed = tall_menu_speed;

		<span>/* If it's smaller, use the short menu height */</span>
		} else if(menu_height < height_value) {
			var speed = short_menu_speed;
		}

		<span>/* slide the menu down */</span>
		this_menu.slideDown(speed);

	},function(){
		<span>/* this is the same but reversed to close the menu */</span>
		var this_menu = $(this).next();
		var menu_height = $(this).next().height();

		<span>/* Calculate the animation speed based on the element height */</span>
		if(menu_height > height_value){
			var speed = tall_menu_speed;
		} else if(menu_height < height_value) {
			var speed = short_menu_speed;
		}
		this_menu.slideUp(speed);

	});

});</code></pre>
<p>That should give you a little more control over the menu speed. I'm sure it needs to be tweaked based on the menu you're using, but the general concept is there, and it should work pretty well. I hope it was helpful. Let me know if you have any additions to the code or suggestions to improve it.</p>
<p class="demo"><a href="http://www.csskarma.com/lab/animation_speed/">View demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.csskarma.com/blog/conditional-animation-speed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Selectable RSS with SimplePie and jQuery</title>
		<link>http://www.csskarma.com/blog/selectable-rss/</link>
		<comments>http://www.csskarma.com/blog/selectable-rss/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 05:45:45 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[advanced]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[simplepie]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.csskarma.com/blog/?p=632</guid>
		<description><![CDATA[I was building an RSS reader for a project last week and it turned out to be a cool little app. So I thought I&#8217;d share some of the code. View demo Download demo files Let&#8217;s start off with the HTML we need to get some user interaction with the form. It&#8217;s a pretty basic, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.csskarma.com/images/articles/simplepieloader.jpg" alt="banner" /></p>
<p>I was building an RSS reader for a project last week and it turned out to be a cool little app. So I thought I&#8217;d share some of the code.</p>
<p class="demo"><a href="http://www.csskarma.com/articles/examples/simplepieloader/">View demo</a></p>
<p class="demo"><a href="http://www.csskarma.com/articles/examples/simplepieloader/simplepieloader.zip">Download demo files</a></p>
<p>Let&#8217;s start off with the HTML we need to get some user interaction with the form. It&#8217;s a pretty basic, just some of checkboxes.</p>
<p><img src="http://www.csskarma.com/images/articles/simplepie_form.png" alt="form with 4 checkboxes" /></p>
<h5>HTML</h5>
<pre><code>&lt;form action="" method="post" id="selection"&gt;
  &lt;h2&gt;Choose your news sources&lt;/h2&gt;
 <span>&lt;!--
  Setting all the checkbox names to "source[] helps us build the array on submit"
  We're also adding the RSS feed url to the checkbox value so we can save it in the array values
  --&gt;</span>
  &lt;ul&gt;
  &lt;li&gt;&lt;input type="checkbox" id="csskarma" name="source[]" value="http://www.csskarma.com/blog/feed/"/&gt;&lt;label for="csskarma"&gt;CSSKarma&lt;/label&gt;&lt;/li&gt;
  &lt;li&gt;&lt;input type="checkbox" id="cnn" name="source[]" value="http://rss.cnn.com/rss/cnn_topstories.rss"/&gt;&lt;label for="cnn"&gt;CNN&lt;/label&gt;&lt;/li&gt;
  &lt;li&gt;&lt;input type="checkbox" id="espn" name="source[]" value="http://sports-ak.espn.go.com/espn/rss/news"/&gt;&lt;label for="espn"&gt;ESPN&lt;/label&gt;&lt;/li&gt;
  &lt;li&gt;&lt;input type="checkbox" id="vitamin" name="source[]" value="http://feeds.feedburner.com/vitaminmasterfeed"/&gt;&lt;label for="vitamin"&gt;Think Vitamin&lt;/label&gt;&lt;/li&gt;
  &lt;/ul&gt;

  <span>&lt;!-- Setting the submit name to "btn" --&gt;</span>
  &lt;input type="submit" value="submit" name="btn" id="btn-submit"/&gt;
  &lt;/form&gt;
  &lt;/div&gt;&lt;!--/#selectnews--&gt;</code></pre>
<p>The only real thing worth noting in the form code are the names of the checkboxes. We use all the same name to group them together and the [ ] helps create the array on submit. I just chose to use <code>source[]</code> because it made sense to me, but you can use anything as long as the names are consistent and the brackets are there. Just adjust your PHP accordingly.</p>
<h5>SimplePie PHP</h5>
<pre><code>&lt;?php
<span>/* Get the SimplePie library */</span>
require_once ('inc/simplepie.inc');

<span>/* Create a new instance of SimplePie */</span>
$feed = new SimplePie();

<span>/* Get array */</span>
<span>// If the form has been submitted and the user selected news sources</span>
if (isset ($_POST['btn']) &amp;&amp; isset($_POST['source'])) {

    <span>// Save the array of news sources to a variable $checked</span>
    $checked = $_POST['source'];

    <span>// Pass the array of news sources through the SimplePie set_feed_url() function</span>
    $feed-&gt;set_feed_url($checked);

    <span>// Also, save this data to a cookie called "feedurls" that will expire when the browser closes</span>
    setcookie('feedurls', serialize($checked));

<span>// If the form wasn't submitted look for the "feedurls" cookie</span>
} else if (isset ($_COOKIE['feedurls'])) {

	<span>// If the cookie was found, pass the data through set_feed_urls()</span>
	$feed-&gt;set_feed_url(unserialize($_COOKIE['feedurls']));
}

<span>/* Set item limit */</span>
$feed-&gt;set_item_limit(3);

<span>/* Enable caching */</span>
$feed-&gt;enable_cache(true);

<span>/* Provide the caching folder */</span>
$feed-&gt;set_cache_location('cache');

<span>/* Set the amount of seconds you want to cache the feed */</span>
$feed-&gt;set_cache_duration(1800);

<span>/* I don't know what "init" means */</span>
$feed-&gt;init();

<span>/* Handle the content type (atom, RSS...) */</span>
$feed-&gt;handle_content_type();
?&gt;</code></pre>
<p>This is nothing that can&#8217;t be read in the comments, but the guts of the PHP comes in right under the &#8220;Get Array&#8221; comment. We&#8217;re checking to see if the form was submitted and the user selected news sources; if so, dump the values into SimplePie and save them to a cookie we can refer to later. The initial idea was for this to live at a pretty open place (a computer lab or something), that&#8217;s why the cookie expires on browser close.</p>
<p>I limited the per-feed output to 3 to keep it a little clean, but you can set that to whatever you want. It&#8217;d be pretty easy to let the user choose this as well with a select menu:</p>
<pre><code>&lt;select name="displayNumber"&gt;
&lt;option value="1"&gt;1&lt;/option&gt;
&lt;option value="2"&gt;2&lt;/option&gt;
&lt;option value="3"&gt;3&lt;/option&gt;
&lt;/select&gt;</code></pre>
<p>And replace <code>$feed-&gt;set_item_limit(3);</code> with <code>$feed-&gt;set_item_limit($_POST['displayNumber']);</code>. There may be some extra tweaking beyond that, but the general idea is to pass the submitted value into SimplePie.</p>
<h5>jQuery</h5>
<p>Now that we have the form fully functional we can layer some JavaScript on top of it to make it a little more <em>nifty</em>. This is using the <a rel="external" href="http://malsup.com/jquery/form/">jQuery Form Plugin</a>. It&#8217;s the first time I&#8217;ve really used this plugin, but it&#8217;s actually pretty nice and easy to use. I had some little quirks with it, but nothing too major.</p>
<pre><code>$(function() {

<span>/* If JavaScript is active create a link to slide the form out */</span>
$('#getform a').click(function(){
	$('#selection').slideToggle('slow');
	return false;
});<span>//</span>

<span>/* make it look like something happened */</span>
$('#selection, #reader').hide(); <span>//</span>
$('#reader').fadeIn('slow'); <span>//</span>

<span> /* bind form using 'ajaxForm' */</span>
$('#selection').ajaxForm(options); 

<span>/* Submit form via Ajax */</span>
var options = {
    target:       '#rssloader',
}; <span>//</span>

});<span>// End jQuery</span></code></pre>
<p class="demo"><a href="http://www.csskarma.com/articles/examples/simplepieloader/">View demo</a></p>
<p class="demo"><a href="http://www.csskarma.com/articles/examples/simplepieloader/simplepieloader.zip">Download demo files</a></p>
<p>Anyway, that&#8217;s all I have for today. It&#8217;s a pretty unpolished demo so let me know what you think, where I screwed up and if you can build on it and make it better. I&#8217;ll try to write some more soon.</p>
<h5>Ingredient list</h5>
<ul>
<li><a rel="external" href="http://simplepie.org/downloads/">SimplePie</a></li>
<li><a rel="external" href="http://css-tricks.com/video-screencasts/55-adding-rss-content-with-simplepie/">Starter files from CSS-Tricks</a></li>
<li><a rel="external" href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.min.js&amp;downloadBtn=">jQuery</a></li>
<li><a rel="external" href="http://malsup.com/jquery/form/">jQuery Form Plugin</a></li>
<li><a href="http://sharkcool.net" rel="external">Hill&#8217;s Brain</a></li>
<li>Coffee</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.csskarma.com/blog/selectable-rss/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
