<?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>The Infinite Loop - Beginner&#039;s SEO, Beginner C# &#38; JQuery Tutorials &#187; Programming</title>
	<atom:link href="http://theinfiniteloopblog.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://theinfiniteloopblog.com</link>
	<description>Problem. Problem Solved. Loop. - The life of a programmer</description>
	<lastBuildDate>Wed, 17 Aug 2011 15:29:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Paging in PHP &#8211; PHP Paging Tutorial</title>
		<link>http://theinfiniteloopblog.com/programming/php/paging-in-php-php-paging-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=paging-in-php-php-paging-tutorial</link>
		<comments>http://theinfiniteloopblog.com/programming/php/paging-in-php-php-paging-tutorial/#comments</comments>
		<pubDate>Sun, 30 May 2010 01:56:07 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[beginner css]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css layout]]></category>
		<category><![CDATA[css techniques]]></category>
		<category><![CDATA[css tricks]]></category>
		<category><![CDATA[custom php paging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tableless design]]></category>
		<category><![CDATA[tableless layout]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://theinfiniteloopblog.com/?p=381</guid>
		<description><![CDATA[<strong>Paging in php and automatic pagination</strong> is something every coder has to deal with when coding in php. I mean, you COULD show all results on 1 page and skip the php paging, but paging is necessary to reduce bandwidth and organize content. Paging is very easy to do and I will walk you through it step by step. 
]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<h2 style="font-size:8pt;">PHP Paging &amp; Automatic Pagination Tutorial - Paging made easy</h2>
<p>I have written a <strong>php paging tutorial</strong> before. Admittedly, it wasn't the greatest. I don't think I was as clear as I wanted to be. SO I'm trying again. <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  At the end of this tutorial, there is a file named <b>php-automatic-pagination.php.txt</b><br />
Please download it! It will help you understand the following.</p>
<p>Here is what we will be making..nice, simple pagers! (Dont worry about the Image #x text, thats really not part of the tutorial)<br />
<a href="http://theinfiniteloopblog.com/wp-content/uploads/2010/05/php-automatic-pagination.jpg" target="_blank"><img src="http://theinfiniteloopblog.com/wp-content/uploads/2010/05/php-automatic-pagination-300x141.jpg" alt="PHP Automatic Pagination/Simple PHP Paging Tutorial" title="php-automatic-pagination" width="300" height="141" class="alignnone size-medium wp-image-400" /></a></p>
<p><strong>Paging in php and automatic pagination</strong> is something every coder has to deal with when coding in php. I mean, you COULD show all results on 1 page and skip the php paging, but paging is necessary to reduce bandwidth and organize content. Paging is very easy to do and I will walk you through it step by step. </p>
<p>PHP automatic paging comes with a few questions:<br />
Paging 1 : Page Size - How many results would you like to display per page?<br />
Paging 2 : How can we bring back proper results in mysql?<br />
Paging 3 : How can we print a pager that will help show the next items.</p>
<p>Decide on your page size - 10, 15, 25, 50, 100. It really depends on what you would like to do.  For this tutorial I will use 15.</p>
<p class="comment">//we want 15 results per page</p>
<p>$pgsize=15; </p>
<p class="comment">//if there is a p variable in the query string e.g: page.php?p=5 we will get this value, else we will use 1 (page 1)</p>
<p>$pg=(is_numeric($_GET["p"]) ? $_GET["p"] : 1); </p>
<p class="comment">//lets determine where we would like to get results from<br />
//if $pg is 1, this calculation results in 0 (we want to start from the first record in the database)<br />
//if $pg is 2, this calculation will result in 1*15..which means we will start at the 15th index of the database (row 16)</p>
<p>$start=($pg-1)*$pgsize; </p>
<p class="comment">//let us query the database for our results<br />
//you will notice LIMIT and $start and $pgsize.<br />
//On page 1, this query will be SELECT * FROM image_table LIMIT 0,15  - this means return 15 rows starting at row-index 0 (row 1)<br />
//On page 2, this query will be SELECT * FROM image_table LIMIT 15, 15 - this means we will return 15 rows starting at row-index 15 (row 16)<br />
//On page 3, this query will be SELECT * FROM image_table LIMIT 30,15 - this means we will return 15 rows starting at row-index 30 (row 31)<br />
GET IT?!?!?!</p>
<p>$imgs=mysql_query("SELECT * FROM image_table LIMIT $start, $pgsize");</p>
<p class="comment">//we will also need the total number of records in our table<br />
//notice there is no limit? we want to know how many records are in the entire table!<br />
//we can use COUNT(*), COUNT(1), or COUNT(fieldname), they will all return the same result</p>
<p>$img_total=mysql_query("SELECT COUNT(1) FROM image_table");</p>
<p class="comment">//mysql_query returns a resource id, we can use this to get the row it has returned</p>
<p>$img_total=mysql_fetch_row($img_total);</p>
<p class="comment">//the count will be the first field in this row</p>
<p>$img_total=$img_total[0];</p>
<p class="comment">//lets determine how many pages we will need<br />
 //WRONG!, this will cut off results..why?<br />
//say we have 31 images, and our page size is 15. 31/15= ~2.x...We need to round this result up!</p>
<p>$max_pages=$img_total / $pgsize; </p>
<p class="comment">//use this line instead</p>
<p>$max_pages=ceil($img_total/$pgsize);</p>
<p>Once we have all this information, we can use a handy little function I have written named printPager. This function will print out a neat little pager. It uses a helper function named add_querystring_var which was from Added Bytes here:<br />
<a href="http://www.addedbytes.com/code/querystring-functions/">http://www.addedbytes.com/code/querystring-functions/</a></p>
<p>Copy/paste this function into your page or into one of your includes:<br />
This will print out your awesome little pager! <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2 style="font-size:1em;">PHP Automatic Pagination Function</h2>
<div style="font-size:0.9em;">
function printPager($max_pages,$pg){<br />
	print '&lt;div class="clear"&gt;&lt;/div&gt;';<br />
	print '&lt;ul class="pager"&gt;';<br />
	$i=1;<br />
	if($pg!=1){<br />
		$url=$_SERVER["SCRIPT_NAME"];<br />
		$url.=add_querystring_var("?".$_SERVER["QUERY_STRING"], "p", $pg-1);<br />
		print '&lt;li class="prev"&gt;&lt;a href="'.$url.'"&gt;&lt;&lt;&lt;/a&gt;&lt;/li&gt;';<br />
	}</p>
<p>	while($i&lt;=$max_pages){<br />
		$url=$_SERVER["SCRIPT_NAME"];<br />
		$url.=add_querystring_var("?".$_SERVER["QUERY_STRING"], "p", $i);</p>
<p>		if($pg==$i){<br />
			print '&lt;li class="current"&gt;';<br />
			print '&lt;span&gt;'.$i.'&lt;/span&gt;';<br />
			print "&lt;/li&gt;";<br />
		}else{<br />
			print "&lt;li&gt;";<br />
			print '&lt;a href="'.$url.'"&gt;'.$i.'&lt;/a&gt;';<br />
			print "&lt;/li&gt;";<br />
		}</p>
<p>		$i++;<br />
	}</p>
<p>	if($pg!=$max_pages){<br />
		$url=$_SERVER["SCRIPT_NAME"];<br />
		$url.=add_querystring_var("?".$_SERVER["QUERY_STRING"], "p", $pg+1);<br />
		print '&lt;li class="next"&gt;&lt;a href="'.$url.'"&gt;&gt;&gt;&lt;/a&gt;';<br />
	}<br />
	print '&lt;/ul&gt;';<br />
	print '&lt;div class="clear"&gt;&lt;/div&gt;';<br />
}</p>
<p>function add_querystring_var($url, $key, $value) { $url = preg_replace('/(.*)(\?|&#038;)' . $key . '=[^&#038;]+?(&#038;)(.*)/i', '$1$2$4', $url . '&#038;'); $url = substr($url, 0, -1); if (strpos($url, '?') === false) { return ($url . '?' . $key . '=' . $value); } else { return ($url . '&#038;' . $key . '=' . $value); } }
</p></div>
<p>Print Pager is called like so:<br />
<?php printPager($max_pages, $pg); ?></p>
<h2 style="font-size:1em;">PHP Pager Styles</h2>
<div style="font-size:0.9em;">
We can style this pager using the following:<br />
/*pagers*/</p>
<p>div.clear{clear:both;}<br />
/spacing between numbers and sizes<br />
ul.pager li {<br />
	float:left;<br />
	margin-right:5px;<br />
	font-size:8pt;<br />
	padding: 2px 5px 2px 5px;<br />
}</p>
<p>//link color<br />
ul.pager li a{<br />
	color:red;<br />
}</p>
<p>//link hover style<br />
ul.pager li a:hover{<br />
	text-decoration:underline;<br />
	color:red;<br />
}</p>
<p>//current page styling<br />
ul.pager li.current span{<br />
	color:red;<br />
}</p>
<p>//previous and next stylings<br />
ul.pager li.prev, ul.pager li.next{</p>
<p>}
</p></div>
<p>Download this tutorials script! It will help you understand. Right click: <a href='http://theinfiniteloopblog.com/wp-content/uploads/2010/05/php-automatic-pagination-tutorial.php.txt'>php-automatic-pagination-tutorial.php</a> and click Save as. Then get rid of the .txt extension and name it php if you would like to run it. You will need to setup a database table to use for the tutorial. It can have an id field and another field.</p>
<p>If you enjoyed this post please leave a comment! I like reading and responding to all my readers!<br />
Thanks</p>
<p><a href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=aburningflame-"><img src="http://tracking.hostgator.com/img/Green/468x60.gif" border=0></a><br />
<strong>Use HostGator 2010 Coupon Code: <em>994offhgpackage</em> for $9.94 off your first month!<br />
(First month will cost $0.01)</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/php/paging-in-php-php-paging-tutorial/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Google SEO Flash &amp; Flash Tips/Techniques</title>
		<link>http://theinfiniteloopblog.com/programming/jscript/google-seo-flash-flash-tipstechniques/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-seo-flash-flash-tipstechniques</link>
		<comments>http://theinfiniteloopblog.com/programming/jscript/google-seo-flash-flash-tipstechniques/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 08:38:08 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SEO/Marketing]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[flash seo techniques]]></category>
		<category><![CDATA[flash seo tips]]></category>
		<category><![CDATA[google seo flash]]></category>
		<category><![CDATA[google seo flash tips]]></category>
		<category><![CDATA[how to seo flash]]></category>
		<category><![CDATA[seo flash]]></category>

		<guid isPermaLink="false">http://theinfiniteloopblog.com/?p=285</guid>
		<description><![CDATA[Google SEO Flash Google currently DOES index flash, however, I believe it is extremely unreliable. Clients have asked me to do some SEO work on their sites, little did I know, these sites were flash! Most crawlers seem to have a hard time crawling flash and the #1 tip I can give for Flash SEO [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<h2>Google SEO Flash</h2>
<p>Google currently DOES index flash, however, I believe it is extremely unreliable. Clients have asked me to do some SEO work on their sites, little did I know, these sites were flash!</p>
<p>Most crawlers seem to have a hard time crawling flash and the #1 tip I can give for Flash SEO is: don't show search engine crawlers flash, show them alternate content!</p>
<p>The reasoning behind this technique:<br />
1) Underlying HTML Content<br />
2) Use javascript to load Flash<br />
3) GoogleBot = No Javascript = Doesn't see flash, sees alternate content</p>
<p>For two of the sites I have worked on, I have used JQuery, JQuery SWFObject Plugin, and a base HTML site to get these sites indexed. Search engine crawlers do not have javascript,  so we will use it to load our flash. If our client has flash and javascript, our client will see Flash. If they dont (Googlebot doesn't have Javascript) they will see our underlying HTML content. Let's take a look at this code:</p>
<p>&lt;div id="flash"&gt;&lt;/div&gt;<br />
&lt;div id="altContent"&gt;<br />
&lt;h1&gt;<strong>Google SEO Flash Tips and Techniques</strong>&lt;/h1&gt;<br />
&lt;h2&gt;<strong>How To SEO Flash for Google</strong>&lt;/h2&gt;<br />
&lt;/div&gt;<br />
On your main page, write &lt;div id="flash"&gt;&lt;/div&gt;, then wrap your Search Engine Optimized code in &lt;div id="altContent"&gt;&lt;/div&gt;.</p>
<p>As you can see, the content in the "altContent" div, is pure html which we can apply the following <a href="http://theinfiniteloopblog.com/?p=19">Basic SEO Techniques </a>to. We have an empty div above with the id "flash". We will use JQuery &amp; the SWFObject to load our flash file into our "flash" div. Since the flash loading is done using javascript, Search Engine Crawlers will not see the flash, but will see our optimized HTML content.</p>
<p>Download a copy of JQuery here:<a href="http://docs.jquery.com/Downloading_jQuery"> http://docs.jquery.com/Downloading_jQuery<br />
</a>and SWFObject plugin here: <a href="http://jquery.thewikies.com/swfobject/downloads"> http://jquery.thewikies.com/swfobject/downloads</a><br />
We will put all our files in the same directory for simplicity, you can put them in a seperate 'scripts' directory if you want to keep organized.</p>
<p>On our main page, we will add the script references (order is important! first load jquery, then the swfobject plugin):&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="jquery.swfobject.js"&gt;&lt;/script&gt;</p>
<p>Now, underneath this, we will add the function to load our flash file:</p>
<ol>
<li>&lt;script&gt;</li>
<li> $("document").ready(function(){</li>
<li> if($.flash.available){</li>
<li> $("#flash").flash({</li>
<li> swf: 'main_flash8.swf',</li>
<li> width:766,</li>
<li> height:750</li>
<li> });</li>
<li> $("#altContent").css("display", "none");</li>
<li> }</li>
<li>});</li>
<li>&lt;/script&gt;</li>
</ol>
<p>This code should be pretty self explanatory, but, let me explain:<br />
Line 2: We are setting up a function to run when our document has been loaded.<br />
Line 3:Check that the user has the flash plugin and it is enabled<br />
Line 4: We are using the .flash() method of SWFObject to load content into the #flash div. (# stands for id  . stands for class)<br />
Line 5: We set the swf: parameter to our swf file<br />
Line 6/7: We set the width/height<br />
Line 9: Now that our flash has loaded, we set the display of the altContent div to none, which will hide it.</p>
<p>Since GoogleBot does not have javascript, the code to load the flash and hide the altContent will never run.<br />
If a user has flash, the flash site will load. If not, they will see the html content.</p>
<p>Searching for my clients business name, they could not be found anywhere. Once I applied the technique above, they were #1 within a week (Search engines do take some time <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>This technique is widely accepted. For some more reading, check out: <a title="Yes, Google Does Index Flash" href="http://www.yourseoplan.com/google-flash/" target="_blank">Google Does Index Flash</a></p>
<p>Hope this article helps.<br />
Comment if it did!</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/jscript/google-seo-flash-flash-tipstechniques/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Professional Table Styling using CSS</title>
		<link>http://theinfiniteloopblog.com/programming/professional-table-styling-using-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=professional-table-styling-using-css</link>
		<comments>http://theinfiniteloopblog.com/programming/professional-table-styling-using-css/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 02:20:30 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=262</guid>
		<description><![CDATA[This tutorial will teach you how to style your tables with css and get them to look professional. It's the little things that make a website that much better.]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>On this blog, I have a post about using jquery to apply alternating table row coloring. Someone commented that they couldnt quite get it working and needed an example. So, while making the example for him, I figure it would be a good post to show how to style a table professionally with CSS.</p>
<p>So, were going to start with this markup: <strong><br />
Note: You only need to load jquery and jquery.scripts if you want to do the last part of this example</strong>.</p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Table Row Coloring Example&lt;/title&gt;<br />
&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;!--load jquery--&gt;<br />
&lt;script type="text/javascript" src="jquery.scripts.js"&gt;&lt;/script&gt; &lt;!--load our custom jquery file--&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="style.css"/&gt;&lt;!--load our css styles--&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;table&gt;<br />
&lt;th&gt;id&lt;/th&gt;<br />
&lt;th&gt;First name&lt;/th&gt;<br />
&lt;th&gt;Last name&lt;/th&gt;<br />
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Scott&lt;/td&gt;&lt;td&gt;Moniz&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr class="row2"&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Bob&lt;/td&gt;&lt;td&gt;Barker&lt;/td&gt;&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>Alright, now that we have that done. We area going to create style.css and add a few rules.</p>
<p>Here is the table selector:<br />
table{</p>
<p>border: 1px solid #ccc;<br />
}</p>
<p>well....that doesnt look very good..YET.<br />
Lets add a rule to the header. We'll add a background color.</p>
<p>table th{<br />
background-color: #ccc;<br />
}</p>
<p>Lets add a rule to the table data tags.<br />
table tr{<br />
border: 1px solid #ccc;<br />
}</p>
<p>Now, lets see what we got so far.<br />
<a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut1.jpg"><img class="aligncenter size-full wp-image-263" title="tabletut1" src="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut1.jpg" alt="tabletut1" width="173" height="84" /></a>Not too bad. You'll notice the headers are a little to close, and the borders dont look too great. Don't worry well fix that. Lets add another couple rules to table th and td.<br />
table th{<br />
border: 1px solid #000;<br />
padding: 5px;<br />
}<br />
table td{<br />
padding: 2px;<br />
}</p>
<p>Alright..lookin good so far. Here's what you should have:<br />
<a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut2.jpg"><img class="aligncenter size-full wp-image-264" title="tabletut2" src="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut2.jpg" alt="tabletut2" /></a>Lets take care of these ugly borders.</p>
<p>On our table selector we will add this rule:</p>
<p>table{<br />
border-collapse: collapse;<br />
}</p>
<p>If you look at the table, you'll notice that on the 2nd row there is a  class="row2". We will now style that class.<br />
table tr.row2{background-color: #EBEBEB;}</p>
<p>DONE. The final result looks like this.</p>
<p><a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut3.jpg"><img class="aligncenter size-full wp-image-266" title="tabletut3" src="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/tabletut3.jpg" alt="tabletut3" width="205" height="88" /></a></p>
<p>You can always modify the styles as you wish.</p>
<p>Tip: Every 2nd row, add the class="row2" to the row to get the alternating row colors. Optionally, add text-align: center; to the table selector.<br />
<a href="http://coulditgetworse.com/theinfiniteloopblog/wp-content/uploads/2009/09/tabletut4.jpg"><img class="aligncenter size-full wp-image-267" title="tabletut4" src="http://coulditgetworse.com/theinfiniteloopblog/wp-content/uploads/2009/09/tabletut4.jpg" alt="tabletut4" width="190" height="186" /></a>Here's the full CSS: <strong><br />
</strong>table{border: 1px solid #ccc;border-collapse:collapse; text-align: center;}<br />
table th{background-color: #ccc; padding: 5px; border: 1px solid #000;}<br />
table td{border: 1px solid #ccc; padding: 2px;}<br />
table tr.row2{background-color: #EBEBEB;}<br />
<strong><br />
Keep reading for an easy way to alternate row colors when you have a lot of rows.</strong><br />
Alright, now, if your table has 20 rows, maybe even 50, or 100, adding row2 manually is really a pain...and I personally wouldn't do that. We will use jquery to color the alternate rows.</p>
<p>Find the &lt;tr class="row2"&gt; and change it to &lt;tr&gt;. If you load the table you'll notice the alternate rows aren't colored anymore. We will now add a class to the table. So &lt;table&gt; should look like this &lt;table class="altcolor"&gt;.</p>
<p>Now that our table is setup, we will use a jquery selector to color rows in any table that has the class altcolor.<br />
You should have jquery.js  and you should create a file named jquery.scripts.js.<br />
Open jquery.scripts.js and add the following:</p>
<p><strong>$("document").ready(function(){<br />
$("table.altcolor tr:even").addClass("row2");<br />
});</strong></p>
<p>This loads when the webpage is ready<br />
//Notice the selector ?<br />
table.altcolor tr:even means any even row, in a table, that has the class "altcolor"<br />
Now we just call addClass, which will add the class row2.<br />
now, the class row2 is added to every even row in a table with the class altcolor.</p>
<p>Done. <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
If you don't get the same result, you might want to download the example source and check it out.</p>
<p><a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/table-example.zip">Download Table Styling Example</a></p>
<p>Tip: When using jquery to style alternate rows, check your table with javascript disabled.<br />
For example, if you style your tables to have white text, and your row2 is supposed to apply a dark background to make the white text show up, if they have javascript disabled, they won't see the white text. Be careful and make sure your table looks good with and without javascript.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/professional-table-styling-using-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easy, Simple Paging Using PHP</title>
		<link>http://theinfiniteloopblog.com/dbs/easy-simple-paging-using-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easy-simple-paging-using-php</link>
		<comments>http://theinfiniteloopblog.com/dbs/easy-simple-paging-using-php/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 07:10:16 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[custom php paging]]></category>
		<category><![CDATA[easy php paging]]></category>
		<category><![CDATA[how to php paging]]></category>
		<category><![CDATA[php automatic pagination]]></category>
		<category><![CDATA[php automatic paging]]></category>
		<category><![CDATA[php pagination]]></category>
		<category><![CDATA[php paging]]></category>
		<category><![CDATA[php paging tutorial]]></category>
		<category><![CDATA[simple php paging]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=243</guid>
		<description><![CDATA[Easy &#38; Simple Paging using PHP. Here is the result: (DB has 8records, Rows per page is set to 5, and we're on page 2) Paging usually takes a while but here we will do it quickly and cleanly. Your page will be named page.php. And when we want to switch pages we will make [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p style="text-align: center;">Easy &amp; Simple Paging using PHP. Here is the result: (DB has 8records, Rows per page is set to 5, and we're on page 2)<br />
<a href="http://coulditgetworse.com/theinfiniteloopblog/wp-content/uploads/2009/09/advertisers1.jpg"><img class="aligncenter size-full wp-image-252" title="advertisers" src="http://coulditgetworse.com/theinfiniteloopblog/wp-content/uploads/2009/09/advertisers1.jpg" alt="advertisers" width="489" height="128" /></a></p>
<p>Paging usually takes a while but here we will do it quickly and cleanly.</p>
<p>Your page will be named page.php. And when we want to switch pages we will make it page.php?pg=2.<br />
Im sure you've seen this before. Anyways lets dive in.</p>
<p>I use shorthand to clean stuff up, but basically shorthand is</p>
<p>$returnvalue=(condition ?  "true" : "false");<br />
Example:</p>
<p>$is_loggedin=(isset($_SESSION["loggedin"]) ? 1 : 0);<br />
After this statement, if the session variable is set, $is_loggedin will equal 1, else it will equal 0.</p>
<p>At the top of your PHP page type the following:</p>
<pre>&lt;?php
/*paging*/
Line 1: $pg=(isset($_GET["pg"]) &amp;&amp; is_numeric($_GET["pg"]) &amp;&amp; $_GET["pg"]&gt;0 ? $_GET["pg"] : 1);
Line 2: $rowsperpage=10;
Line 3: $offset=($pg&gt;1 ? ($pg-1)*$rowsperpage : 0 );
Line 4: $limitstr=" LIMIT $offset, $rowsperpage";
?&gt;</pre>
<p>Explanation:<br />
First of all Limit is : LIMIT $startrowid, $number of entries to return<br />
So LIMIT 55, 5  means start at row 55 and return 5 rows (55, 56, 57, 58, 59)</p>
<p><strong>Line 1</strong>: If in the query string the pg is set  e.g page.php?pg=4, and it is numeric, and greater than 0 we will assign the value of $_GET["pg"] to our $pg variable. If it is not set, or it is not numeric, or zero or less, we set the $pg variable to 1.<br />
<strong>Line 2</strong>: We set our rows per page<br />
<strong>Line 3</strong>: If the page is greater than 1, we set the offset to ($pg-1)*rowsperpage. If the page is 1 or less, we set offset to 0.<br />
<strong>Line 4</strong>: We create the limit string for the sql statement. This will output something like LIMIT x, y.<br />
(rowsperpage set to 10)</p>
<p>In this case page.php?pg=1<br />
$pg = 1;<br />
$offset = 0;<br />
$rowsperpage=10;<br />
$limitstr="LIMIT 0, 10"; //this string will pull 10 rows starting from row 0 (the first row) (rows 0-9)</p>
<p>In this case page.php?pg=3<br />
$pg=3;<br />
$offset= (3-1) * 10;  //offset calculates to 20<br />
$limitstr="LIMIT 20, 10";  //this string will pull 10 rows starting from  and including row 20 (rows 20-29)</p>
<p><strong>Ok. Now that we got that out of the way.</strong></p>
<p>We will use a simple query, then we will attach our new limit string (looking at case 2 above)<br />
$sql="SELECT * FROM MEMBERS $limitstr"; //sql = "SELECT * FROM MEMBERS LIMIT 20,10";<br />
$res=mysql_query($sql);<br />
while($row=mysql_fetch_array($res)){</p>
<p>//processing if you need to<br />
}</p>
<p>We also need to know the total count for this table<br />
$sql="SELECT COUNT(memberid) FROM MEMBERS";<br />
$res=mysql_query($sql);<br />
$row=mysql_fetch_array($res);<br />
$total = $row[0];</p>
<p>Now we know the total count.</p>
<p>So we need to calculate the number of pages. That is done by this formula:<br />
($total/$rowsperpage);<br />
Now in the case of 26 members and 5 rows per page. Using this formula 26/5 =  5.2pages, so we need to round up!</p>
<p>$maxpage=ceil($total/$rowsperpage); //max page is now 6.</p>
<p>Ok, we got everything set up <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Just need to print out our paging!<br />
Wherever you want your paging setup add this:</p>
<pre>&lt;?php
print '&lt;div class="paging"&gt;&lt;ul&gt;';
for($i=1; $i&lt;=$maxpage; $i++){
  if($pg==$i)
     print '&lt;li&gt;&lt;span&gt;'.$i.'&lt;/span&gt;&lt;/li&gt;';
  else
     print '&lt;li&gt;&lt;a href="?pg='.$i.'"&gt;'.$i.'&lt;/a&gt;&lt;/li&gt;';
}
print "&lt;/ul&gt;&lt;/div&gt;";
?&gt;</pre>
<p>Then we can do some nice styling (Mess around with margins to setup spacing)<br />
CSS<br />
div.paging {text-align: center; margin-top: 5px;}<br />
div.paging span{font-weight: bold;}<br />
div.paging ul{overflow: hidden;}<br />
div.paging ul li{width: 10px; float: left; margin: 0px 10px 5px 0px;}</p>
<p>This will page across until it hits the edge of the div, then it will move to the next line.</p>
<p>ENJOY and comment ! <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/dbs/easy-simple-paging-using-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Easy Javascript Validation using JQuery</title>
		<link>http://theinfiniteloopblog.com/programming/easy-javascript-validation-using-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easy-javascript-validation-using-jquery</link>
		<comments>http://theinfiniteloopblog.com/programming/easy-javascript-validation-using-jquery/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 03:45:55 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[easy javascript validation]]></category>
		<category><![CDATA[easy jquery validation]]></category>
		<category><![CDATA[easy jquery validator]]></category>
		<category><![CDATA[jquery validation plugin]]></category>
		<category><![CDATA[jquery validator]]></category>
		<category><![CDATA[jquery validator plugin]]></category>
		<category><![CDATA[jquery.validator.js]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=234</guid>
		<description><![CDATA[Now, there might be other tools out there, but this is how I do mine. I like to write stuff from scratch but I actually feel like this little script would make life easier for a lot of people. You're free to use this as long as you leave the copyright in there. First download [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>Now, there might be other tools out there, but this is how I do mine. I like to write stuff from scratch but I actually feel like this little script would make life easier for a lot of people. You're free to use this as long as you leave the copyright in there.</p>
<p>First download jQuery and this script:  <a title="Jquery Validator" href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/jquery.validator.js"> jquery.validator.js</a> (Right click&gt;Save As)<br />
Next, add these lines.</p>
<p>&lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;<br />
&lt;script src="jquery.validator.js" type="text/javascript"&gt;&lt;/script&gt;</p>
<p>When you create your forms create them like this.<br />
The form must have an id, and it must have the class "validate".<br />
Add the class 'req' for any fields that are required.<br />
Coming soon: email, int verification, age, etc.</p>
<pre>&lt;form <strong>id</strong>="contactform" action="whatever_action_you_want.php" <strong>class</strong>="validate"&gt;
&lt;input type="text" name="firstname" class="req"/&gt;&lt;span class="val"&gt;*&lt;/span&gt;
&lt;input type="text" name="lastname" class="req"/&gt;&lt;span class="val"&gt;*&lt;span&gt;
&lt;select name="country req"&gt;
&lt;option value=""&gt;Please select&lt;/option&gt;
&lt;option value="CA"&gt;Canada&lt;/option&gt;
&lt;/select&gt;
&lt;/form&gt;</pre>
<p>In your css add these<br />
span.val{visibility: hidden; color: red; font-weight:bold;}</p>
<p>Thats it.</p>
<p>If you guys post comments and subscribe, I can let you know when i further develop this. It will include number verification, email verification, postal code verification. It's very simple and lightweight and will shave time off any project. File (Right click>Save As): <a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/09/jquery.validator.js">jquery.validator</a></p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/easy-javascript-validation-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Embedding flash using SWFObject</title>
		<link>http://theinfiniteloopblog.com/programming/embedding-flash-using-swfobject/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=embedding-flash-using-swfobject</link>
		<comments>http://theinfiniteloopblog.com/programming/embedding-flash-using-swfobject/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 10:09:53 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[flash embed]]></category>
		<category><![CDATA[flash embedding]]></category>
		<category><![CDATA[swfobject embed]]></category>
		<category><![CDATA[swfobject flash help]]></category>
		<category><![CDATA[swfobject flash method]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=229</guid>
		<description><![CDATA[Just to save some of you the headache . I spent a few hours on this today, and I couldn't figure it out, I've embedded flash many times before and I just couldn't figure out why this time it wasn't working. Anyways Using jquery found here: http://docs.jquery.com/Downloading_jQuery and jquery swfobject plugin found here: http://jquery.thewikies.com/swfobject/downloads we [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>Just to save some of you the headache <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I spent a few hours on this today, and I couldn't figure it out, I've embedded flash many times before and I just couldn't figure out why this time it wasn't working.</p>
<p>Anyways</p>
<p>Using jquery found here: http://docs.jquery.com/Downloading_jQuery<br />
and<br />
jquery swfobject plugin found here: http://jquery.thewikies.com/swfobject/downloads</p>
<p>we can semantically embed flash.</p>
<p>Now a few things:</p>
<pre>
&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.swfobject.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.myscript.js"&gt;&lt;/script&gt;</pre>
<p>Make SURE these are in this EXACT order.<br />
Load Jquery>Load its plugins>Load your javascript file.</p>
<p>Now on your page somewhere you will have the div you want to load flash into like so:<br />
&lt;div id="myflashdiv"&gt;&lt;/div&gt;</p>
<p>Open up jquery.myscript.js and type:</p>
<pre>
$("document").ready(function(){
       $("#myflashdiv").flash({
               swf: 'flash/myflash.swf'
        });
});
</pre>
<p>Directory Structure:</p>
<pre>
flash
  -myflash.swf
script
  -jquery.myscript.js
index.html
</pre>
<p>This assumes you have a flash folder, and the file myflash.swf in that folder.<br />
The path in this case is NOT relative to the script your working in. Think about it this way:<br />
the flash method probably uses document.write to output the correct object tag for your flash.<br />
If your page is on the root of your site and the script is in scripts/jquery.myscripts.js you would think the source for the swf would be "../flash/myflash.swf". But think about that..in index.html if you look at the output it would say: src="../flash/myflash.swf", you should be able to see why thats wrong if you look at the above directory structure.</p>
<p>Anyways, if you didn't know swfobject behaves this way, this could take you quite some time to figure out.<br />
Hope I saved you that time <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Troubleshooting<br />
Tip 1: Make sure the load order is : jquery, jquery.swfobject.js, then your script.<br />
Tip 2: Make sure the src you're passing in  is relative to the page you're embedding on, NOT relative to the script file you're working in.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/embedding-flash-using-swfobject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursing through a directory/filesystem using C#</title>
		<link>http://theinfiniteloopblog.com/gen/recursing-through-a-directoryfilesystem-using-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=recursing-through-a-directoryfilesystem-using-c</link>
		<comments>http://theinfiniteloopblog.com/gen/recursing-through-a-directoryfilesystem-using-c/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 21:34:37 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=220</guid>
		<description><![CDATA[This will teach you how to recurse through a directory/filesystem using C#.. The problem comes from not knowing how many folders/files exist. One folder can have many folders inside it, those folders can each have many folders inside it. I will show you how to recurse through the filesystem and explain it so that you [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>This will teach you how to <strong>recurse through a directory/filesystem using C#.</strong>.<br />
The problem comes from not knowing how many folders/files exist.<br />
One folder can have many folders inside it, those folders can each have many folders inside it.</p>
<p>I will show you how to recurse through the filesystem and explain it so that you UNDERSTAND it. This isnt for copy-paste.</p>
<p>We will start with a C# console application and pick a path, we'll use C: for this.<br />
First of all, we're going to need the IO namespace. The IO namespace has access to File and Directory methods.</p>
<p>At the top add these lines:</p>
<pre>
using System; //Just so we can use the shortcut Console instead of System.Console
using System.IO; //Gives us access to file, directory objects</pre>
<p>Now, in our "main" method, we are going to write the following:</p>
<pre>
string path="C:/"; //set the root path we want to recurse through.

//check if the directory exists
if(Directory.Exists(path)){
        DirectoryInfo di=new DirectoryInfo(path);
        //based on a path, this object will give you directory information about that directory
        printDirectories(di);
        //this method will actually go through our directories and print out information
}else{
        Console.WriteLine("Directory does not exist. Press Enter to exit");
        Console.ReadLine(); //when you hit return the program will terminate.
}
</pre>
<p><!--adsense--><br />
Now we will write the print directories method. It takes a DirectoryInfo object as a parameter and will use that to recurse through the file system.</p>
<p>//declared as static because were a console app, this can be private in your application if it a utility method.<br />
2 Important methods we're going to be looking at are in the DirectoryInfo object. They are</p>
<p>public FileInfo[] directoryInfoObject.GetFiles() //returns an array of FileInfo objects<br />
public DirectoryInfo[] directoryInfoObject.GetDirectories() //returns an array of DirectoryInfo objects</p>
<pre>static void printDirectories(DirectoryInfo di){
       foreach(FileInfo fi in di.GetFiles()){
              //we are going to run code for each file
              Console.WriteLine(fi.FullName); //this prints out the full file name including the path
       }

      //now that we process this directory for files, we do the same for every subdirectory in this directory
      foreach(DirectoryInfo subDir in di.GetDirectories()){
             //we are going to call the printDirectories method, with the subdirectory as the root.
            //its files will be processed, then its subdirectories will be checked
            //this happens foreach Directory in the current directory
            printDirectories(subDir); //recurse
      }
}</pre>
<p>Thats simple recursion. The most common use of this is for populating a treeview and another use that comes to mind is file searching. Keep an eye out for the next tutorial: Populating a Treeview from a file system!</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/gen/recursing-through-a-directoryfilesystem-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating/Retrieving a GUID object from a string C#</title>
		<link>http://theinfiniteloopblog.com/programming/creatingretrieving-a-guid-object-from-a-string-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creatingretrieving-a-guid-object-from-a-string-c</link>
		<comments>http://theinfiniteloopblog.com/programming/creatingretrieving-a-guid-object-from-a-string-c/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 23:35:01 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=216</guid>
		<description><![CDATA[GUIDS are great to use if you ever may need to merge data. The chances of collision (duplicates) are extremely low. To generate a new guid, use this code: Guid g=Guid.NewGuid(); //this generates a GUID object Guid g2=Guid.NewGuid().ToString(); //this generates a GUID string There may be a time where in a stored procedure, you have [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>GUIDS are great to use if you ever may need to merge data.<br />
The chances of collision (duplicates) are extremely low.</p>
<p>To generate a new guid, use this code:<br />
Guid g=Guid.NewGuid(); //this generates a GUID object<br />
Guid g2=Guid.NewGuid().ToString(); //this generates a GUID string<br />
<br/><br />
<!--adsense--><br />
<br/><br />
There may be a time where in a stored procedure, you have a GUID as a parameter.</p>
<p>In C# you may have to pass this paramater to the procedure.<br />
This is actually very simple.</p>
<p>Given a string that you know is a GUID, you can retrieve a guid object like so:<br />
Guid g=new Guid(myStringGUID);</p>
<p>And thats all folks <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/creatingretrieving-a-guid-object-from-a-string-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Javascript Alert and Confirm Dialog boxes</title>
		<link>http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=custom-javascript-alert-and-confirm-dialog-boxes</link>
		<comments>http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 18:50:54 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[change javascript alert button]]></category>
		<category><![CDATA[change javascript alerts]]></category>
		<category><![CDATA[change javascript button text]]></category>
		<category><![CDATA[change javascript confirm button text]]></category>
		<category><![CDATA[custom dialog boxes]]></category>
		<category><![CDATA[custom javascript alerts]]></category>
		<category><![CDATA[custom javascript dialog boxes]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=204</guid>
		<description><![CDATA[This article will teach you how to make Custom Javascript Alert and Confirm Dialog boxes, and change the button text on dialog boxes. For the most part, custom alert and confirm dialogs are not possible because alert and confirm dialog boxes are handled by the browser, however, there is a great JQuery plugin that will [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<h2>This article will teach you how to make Custom Javascript Alert and Confirm Dialog boxes, and change the button text on dialog boxes.</h2>
<p>For the most part, custom alert and confirm dialogs are not possible because alert and confirm dialog boxes are handled by the browser, however, there is a great JQuery plugin that will let you customize your alert boxes. If you don't know JQuery, do not worry, because i'll take you through it step by step. This little customization can make your web application that much more professional.</p>
<p>This will show you a little tutorial on how to make the custom alert and confirm dialogs AND <strong>How to return values from a custom confirm dialog box</strong>. This is EXTREMELY important. I have seen a lot of tutorials on how to do this, but none of them talk about actually <strong>retrieving the value of the response  in a custom confirm dialog box.</strong>.</p>
<h2>Custom Javascript Alert Dialog Boxes</h2>
<p><strong>Step 1 : Download <a href="http://docs.jquery.com/Downloading_jQuery">JQuery</a></strong></p>
<p>Click on Current Release, you can click Uncompressed if you want to inspect the code, but you should use minified version for production.</p>
<p>In our site, we will make a folder called scripts, and we will put the jquery.js file into this folder.<br />
We will also make a new file in the same folder named jquery.scripts.js.</p>
<p><strong>Step 2: Download </strong><a href="http://theinfiniteloopblog.com/wp-content/uploads/2009/07/jquery.alerts.js">jquery.alerts (Right click, Save as)</a>  and the css here: <a href='http://theinfiniteloopblog.com/wp-content/uploads/2009/07/jquery.alerts.css'>jquery.alerts.css</a><br />
</a> NOTE: This plugin is no longer supported by http://abeautifulsite.net/, so use it at your own risk.</p>
<p>We will put the jquery.alerts.js into the scripts folder, and the jquery.alerts.css into a styles folder.</p>
<p><strong>Step 3: The Setup</strong><br />
In our webpage we will add the references to these file.</p>
<p>&lt;script type="text/javascript" src="scripts/jquery.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="scripts/jquery.scripts.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="scripts/jquery.alerts.js"&gt;&lt;/script&gt;<br />
&lt;link href="styles/jquery.alerts.css" rel="stylesheet"/&gt;</p>
<p>Once we have all these references in, we're ready to write some jquery.</p>
<p><strong>Step 4: Open jquery.scripts.js</strong><br />
Type</p>
<p>$("document").ready(function(){</p>
<p>});</p>
<p>This sets up a function to be run when our document is ready.</p>
<p>In this document.ready function, type<br />
alert('jquery loaded');</p>
<p>Refreshing your webpage, you should see an alert saying "jquery loaded", if you see this, you have setup jquery correctly. If you do not, check the steps above, or hit CTRL+F5, this does a cache refresh and requests a new copy of all the javascript and css files.</p>
<p>We will add a button to our site.<br />
&lt;input type="button" value="Custom Alert" id="customAlert"/&gt;</p>
<p>In our document ready function, we will hook up a handler to handle the "click" event of this button.</p>
<p>$("document").ready(function(){<br />
$("#customAlert").click(function(){<br />
alert('this is an alert');<br />
});<br />
});</p>
<p>If you refresh your webpage (CTRL+F5) and click the button, you should see a normal javascript popup.<br />
Now, change the alert to jAlert.<br />
jAlert('this is a custom alert', 'this is a custom title');</p>
<p>Upon refreshing the page, and clicking the button, you should see a custom grey alert box.<strong> </strong>The styles can be modified by editing jquery.alerts.css.</p>
<p><strong>If you'd like to read on Custom confirm dialog boxes, please continue reading.</strong><br />
By this point, jquery and the jquery alerts plugin and css should be setup.<br />
Follow the above tutorial until you get to the actual jAlert method.</p>
<p><em>Comment if this helped! <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
<h2>Custom Javascript Confirm Dialog Boxes</h2>
<p>Now, we will do a <strong>Custom Javascript Confirm Dialog.</strong><br />
The confirm function looks like this<br />
<strong>jConfirm('msg', '[title]', [callback function]);</strong></p>
<p>$("document").ready(function(){<br />
$("#btnID").click(function(){<br />
jConfirm('Would you like Ice Cream', 'msgBox Title', function(r){<br />
if(r){<br />
alert('you replied yes!');<br />
}else{<br />
alert('you replied no!');<br />
}<br />
}<br />
});<br />
});<br />
This is the basic implementation of custom confirm boxes, however you can still customize these a little further.</p>
<h2><strong>Changing Javascript Alert Button Text</strong></h2>
<p>Before calling jAlert or jConfirm, you can set the button text.</p>
<p>$.alerts.okButton="OKAYYYYYYYYYY";<br />
$.alerts.cancelButton="CANCELLLLLLLLLL";</p>
<p>This is also useful for localization.<br />
For example in an english jquery.scripts.js you can have.</p>
<p>$.alerts.okButton = "yes";<br />
$.alerts.cancelButton = "no";</p>
<p>And in a french jquery.scripts.js you can have</p>
<p>$.alerts.okButton="oui";<br />
$.alerts.okButton="non";</p>
<p>Hopefully this helped you add that little extra touch.<br />
For reference, here are the 2 methods, only the msg parameter is required.</p>
<p>jAlert('msg', '[title]', [callback function]);<br />
jConfirm('msg', '[title]', [callback functoin]);</p>
<p>There you have it!<br />
<em><strong>Please comment if this was helpful <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </strong></em><br />
Goodluck with your custom javascript!</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Using javascript to opening a new window W3C Validation target=&quot;_blank&quot; alternative</title>
		<link>http://theinfiniteloopblog.com/gen/semantically-opening-a-new-window-instead-of-using-target_blank/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=semantically-opening-a-new-window-instead-of-using-target_blank</link>
		<comments>http://theinfiniteloopblog.com/gen/semantically-opening-a-new-window-instead-of-using-target_blank/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 02:05:29 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[javascript open link in new window]]></category>
		<category><![CDATA[javascript open new window]]></category>
		<category><![CDATA[open link in new window]]></category>
		<category><![CDATA[open link in new window strict]]></category>
		<category><![CDATA[open link in new window validation]]></category>
		<category><![CDATA[open link in new window xhtml strict]]></category>
		<category><![CDATA[target="_blank" semantically]]></category>
		<category><![CDATA[W3C Validation]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=170</guid>
		<description><![CDATA[&#60;a href="http://www.google.com" target="_blank"&#62;Google!&#60;/a&#62; Perfect way to open a new window right? WRANG! (End of the world flash reference ...look it up) Your webpages may not pass W3C validation because your still using target="_blank". This article will show you how to use javascript or jquery to open a new window, and have your webpages pass W3C [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>&lt;a href="http://www.google.com" target="_blank"&gt;Google!&lt;/a&gt;<br />
Perfect way to open a new window right? WRANG! (End of the world flash reference ...look it up)</p>
<p>Your webpages may not pass W3C validation because your still using target="_blank".<br />
This article will show you how to use javascript or jquery to open a new window, and have your webpages pass W3C Strict Validation.</p>
<p>Anyyyyyyyyyyyways, using the target attribute of the a tag was a perfectly valid way of opening a link in a new window. However, this currently does not pass certain XHTML Validations. I assume you found this blog post because you need to validate and target="_blank" isn't passing.</p>
<p>This solution will open your link in a new window.<br />
&lt;a href="http://www.google.com" onclick="window.open(this.href);return false;"&gt;Google New Window!&lt;/a&gt;</p>
<p>What this does is use window.open, and passes the links href attribute as the url.<br />
The reason for "return false", is so that the base web page does not open the link as well.</p>
<p>Another cool alternative is to use JQuery...ya I know this is javascript but if you have jquery already loaded you can add this to your document.ready function.</p>
<p>$(document).ready(function(){<br />
$("a.newWin").click(function(){<br />
window.open($(this).attr("href"));<br />
return false;<br />
});<br />
});</p>
<p>&lt;a href="http://www.google.com" class="newWin"&gt;Google&lt;/a&gt;</p>
<p>Any link with the class newWin will now open in a new window.</p>
<p>Both these methods validate to XHTML Strict and are easy to implement.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/gen/semantically-opening-a-new-window-instead-of-using-target_blank/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

