<?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>Phillip Napieralski &#187; Magic: The Gathering</title>
	<atom:link href="http://blog.pnapieralski.com/tag/magic-the-gathering/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pnapieralski.com</link>
	<description>Programmer, Engineer, Researcher.</description>
	<lastBuildDate>Tue, 20 Dec 2011 16:41:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Clickable Table Rows with jQuery</title>
		<link>http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/</link>
		<comments>http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 22:51:29 +0000</pubDate>
		<dc:creator>Phillip Napieralski</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Magic: The Gathering]]></category>

		<guid isPermaLink="false">http://blog.pnapieralski.com/?p=9</guid>
		<description><![CDATA[<a href="http://www.pnapieralski.com/tuts/jquery-2-rowselect" rel="shadowbox">Check out the demo here!</a>

This is a quick tutorial that will help in a future project that I'm doing, which is a Magic: The Gathering deck building application.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pnapieralski.com/tuts/jquery-2-rowselect" rel="shadowbox">Check out the demo here!</a></p>
<p>This tutorial hints at a project I&#8217;m working on. A deck building application for the Magic: The Gathering card game.</p>
<h2>Highlighting Rows</h2>
<p>In <a href="http://blog.pnapieralski.com/jquery/jquery-selectors-2/">jQuery Selectors 2</a>, I talked about how to highlight certain rows in a table. We can build off this to begin a full sized app (at least the frontend) with jQuery.</p>
<p>To recap briefly, we allow rows be clickable by using the following code:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function() {
	$(&quot;tr&quot;).click(function(){
		// store our selection of the row that was clicked
		row = $(this);

		// toggle the &quot;selected&quot; class for the clicked row
		row.toggleClass(&quot;selected&quot;);
	});
});
</pre>
<p>Note first that the code is inside the $(document).ready(&#8230;) function. This will be the case for the code in the rest of this post.</p>
<h2>Show Card Selections</h2>
<p>How do we know what the user selected? Well, we can accomplish that task with the following code:</p>
<pre class="brush: jscript; title: ; notranslate">
	// check for a button click
	$(&quot;#show_button&quot;).click(function(){
		var cards = &quot;&quot;;

		// search through each row that has the &quot;selected&quot; class
		$(&quot;tr.selected&quot;).each(function() {
			// append the card name (which is between &lt;th&gt; tags) to our cards variable
			cards += $(this).find(&quot;th&quot;).html();
			cards += &quot;\n&quot;;
		});

		// Simply alert the user what they selected for now
		alert(&quot;You selected:\n&quot;+cards);
	});
</pre>
<p>There you have it. The next step is to replace the alert(&#8220;&#8221;) piece with a $.post(&#8230;) request to a php script with the selected cards. </p>
<h2>Next Time</h2>
<p>Lost on this tutorial? Try <a href="http://blog.pnapieralski.com/jquery/jquery-selectors-2/">part 2</a></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Clickable+Table+Rows+with+jQuery&amp;link=http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/&amp;notes=Check%20out%20the%20demo%20here%21%0D%0A%0D%0AThis%20is%20a%20quick%20tutorial%20that%20will%20help%20in%20a%20future%20project%20that%20I%27m%20doing%2C%20which%20is%20a%20Magic%3A%20The%20Gathering%20deck%20building%20application.&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%2524%257Btitle%257D%2B-%2B%2524%257Bshort_link%257D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-digg">
			<a href="http://www.shareaholic.com/api/share/?title=Clickable+Table+Rows+with+jQuery&amp;link=http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/&amp;notes=Check%20out%20the%20demo%20here%21%0D%0A%0D%0AThis%20is%20a%20quick%20tutorial%20that%20will%20help%20in%20a%20future%20project%20that%20I%27m%20doing%2C%20which%20is%20a%20Magic%3A%20The%20Gathering%20deck%20building%20application.&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=3&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Clickable+Table+Rows+with+jQuery&amp;link=http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/&amp;notes=Check%20out%20the%20demo%20here%21%0D%0A%0D%0AThis%20is%20a%20quick%20tutorial%20that%20will%20help%20in%20a%20future%20project%20that%20I%27m%20doing%2C%20which%20is%20a%20Magic%3A%20The%20Gathering%20deck%20building%20application.&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://www.shareaholic.com/api/share/?title=Clickable+Table+Rows+with+jQuery&amp;link=http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/&amp;notes=Check%20out%20the%20demo%20here%21%0D%0A%0D%0AThis%20is%20a%20quick%20tutorial%20that%20will%20help%20in%20a%20future%20project%20that%20I%27m%20doing%2C%20which%20is%20a%20Magic%3A%20The%20Gathering%20deck%20building%20application.&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=10&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Clickable+Table+Rows+with+jQuery&amp;link=http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/&amp;notes=Check%20out%20the%20demo%20here%21%0D%0A%0D%0AThis%20is%20a%20quick%20tutorial%20that%20will%20help%20in%20a%20future%20project%20that%20I%27m%20doing%2C%20which%20is%20a%20Magic%3A%20The%20Gathering%20deck%20building%20application.&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Clickable+Table+Rows+with+jQuery&amp;link=http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/&amp;notes=Check%20out%20the%20demo%20here%21%0D%0A%0D%0AThis%20is%20a%20quick%20tutorial%20that%20will%20help%20in%20a%20future%20project%20that%20I%27m%20doing%2C%20which%20is%20a%20Magic%3A%20The%20Gathering%20deck%20building%20application.&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.pnapieralski.com/jquery/clickable-table-rows-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

