<?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>BLUEice studios &#187; jQuery</title>
	<atom:link href="http://www.blueicestudios.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blueicestudios.com</link>
	<description>I make stuff for you :)</description>
	<lastBuildDate>Wed, 20 Jul 2011 09:07:32 +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>jQuery: Filter Select box with php and mysql</title>
		<link>http://www.blueicestudios.com/jquery-filter-select-box-with-php-and-mysql/</link>
		<comments>http://www.blueicestudios.com/jquery-filter-select-box-with-php-and-mysql/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 00:58:33 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[select box]]></category>

		<guid isPermaLink="false">http://www.blueicestudios.com/?p=140</guid>
		<description><![CDATA[Lets filter a select box with jQuery, Sack, PHP and MySQL&#8230;.. You may or may not need this, but it could come in handy at one point in time. So lets start.. I will show you the basics here, you may download the source at the bottom of the page. View the DEMO index.html include [...]]]></description>
			<content:encoded><![CDATA[<p>Lets filter a select box with jQuery, Sack, PHP and MySQL&#8230;..</p>
<p>You may or may not need this, but it could come in handy at one point in time. So lets start..</p>
<p>I will show you the basics here, you may download the source at the bottom of the page.</p>
<p><span id="more-140"></span></p>
<p>View the <a href="http://www.blueicestudios.com/filter_select/" target="_blank">DEMO</a></p>
<p>index.html</p>
<p>include these into the head section of the page. ajax.js is the Sack js functions. I will get into Sack later.</p>
<pre class="brush:html"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"><!--mce:0--></script> <script src="sack.js" type="text/javascript"><!--mce:1--></script></pre>
<p>this goes into the head as well.</p>
<pre class="brush:js">var ajax = new Array();

function getTextList(sel)

{

var color = document.getElementById('color').value; //gets value from text input

document.getElementById('colorReturn').options.length = 0;

if(color.length&gt;0){

var index = ajax.length;

ajax[index] = new sack();

ajax[index].requestFile = 'getColor.php?color='+color; //sends the GET to the php page

ajax[index].onCompletion = function(){ createText(index) };

ajax[index].runAJAX();

}

}

function createText(index)

{

var obj = document.getElementById('colorReturn'); //retruns the options from the php page

eval(ajax[index].response);

}</pre>
<p>The form</p>
<pre class="brush:html">
<form method="post">
<select id="colorReturn" style="width: 200px;" name="colorReturn" size="5">
</select>
<h4>Filter the colors - Start typing black.</h4>
<input id="color" onkeyup="getTextList();" name="color" type="text" />
</form>
</pre>
<p>Thats it for the index page. pretty straight forward. So now for the fun part.</p>
<p>getColor.php &#8211; This page contains the sql and php that returns the</p>
<pre class="brush:php">mysql_connect("localhost", "username", "password") or die(mysql_error());

mysql_select_db("database") or die(mysql_error());

$color = $_GET['color'];

if(isset($_GET['color'])){

$result = mysql_query("SELECT color FROM colors WHERE color LIKE '%$color%' LIMIT 0,10")

or die(mysql_error());

while($color = mysql_fetch_array( $result ))

{

echo 'obj.options[obj.options.length] = new Option("'.$color['color'].'","'.$color['color'].'");';

}

}</pre>
<p>Its not the most detailed tutorial, but im not a tutorial guy.</p>
<p>View the <a href="http://www.blueicestudios.com/filter_select/" target="_blank">DEMO</a></p>
<p>Download the <a href="http://www.blueicestudios.com/filter_select/getColor.zip">SOURCE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blueicestudios.com/jquery-filter-select-box-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Chained Select Boxes using PHP / MySQL / AJAX / jQuery</title>
		<link>http://www.blueicestudios.com/chained-select-boxes-using-php-mysql-ajax/</link>
		<comments>http://www.blueicestudios.com/chained-select-boxes-using-php-mysql-ajax/#comments</comments>
		<pubDate>Sat, 05 Jan 0210 11:42:12 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[chained select boxes]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.blueicestudios.com/?p=123</guid>
		<description><![CDATA[UPDATE Well everyone, I&#8217;m almost done with the generator!! Watch this short clip to see it in action. If you are interested in this tool it is for sale, while I get together a payment system you can contact me about trying out a beta. DEMO 2 and 3 Dropdowns available in the download. It [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>UPDATE</strong></span></p>
<p><span style="color: #ff0000;"><strong>Well everyone, I&#8217;m almost done with the generator!! </strong></span></p>
<p><span style="color: #ff0000;"><strong>Watch this short clip to see it in action.</strong></span></p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/_f9sJCatmDg?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/_f9sJCatmDg?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object><br />
</strong></span></p>
<p><span id="more-123"></span></p>
<p>If you are interested in this tool it is for sale, while I get together a payment system you can <a href="http://www.blueicestudios.com/contact-us/">contact me</a> about trying out a beta.</p>
<p><a href="http://blueicestudios.com/chained-select-boxes/" target="_blank">DEMO</a></p>
<p>2 and 3 Dropdowns available in the download.</p>
<p style="text-align: center;"><a href="http://blueicestudios.com/chained-select-boxes/" target="_blank"><img class="size-full wp-image-207 aligncenter" title="tier" src="http://www.blueicestudios.com/wp-content/uploads/0210/05/tier.jpg" alt="tier" width="425" height="85" /></a></p>
<p>It is fairly simple and consists of only 3 files. An index, database connection and a function file. So lets start.</p>
<p>Make your database table and fields. you can use mine for now.</p>
<pre class="brush:php">CREATE TABLE IF NOT EXISTS `two_drops` (
  `id` int(11) NOT NULL auto_increment,
  `tier_one` varchar(255) NOT NULL,
  `tier_two` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM ;

INSERT INTO `two_drops` (`id`, `tier_one`, `tier_two`) VALUES
(1, 'Colors', 'Red'),
(2, 'Colors', 'Blue'),
(3, 'Colors', 'Green'),
(4, 'Colors', 'Yellow'),
(5, 'Colors', 'Black'),
(6, 'Shapes', 'Square'),
(7, 'Shapes', 'Circle'),
(8, 'Shapes', 'Triangle'),
(9, 'Shapes', 'Rectangle'),
(10, 'Shapes', 'Oval');</pre>
<p>Make your connection to your database. <strong><em>db.php</em></strong></p>
<pre class="brush:php">mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());</pre>
<p>Next we will add the jQuery, loading, results and main form in <strong><em>index.php</em></strong></p>
<p>add your includes at the top of the page.</p>
<pre class="brush:php">  //include your database connection and function files.
  include('db.php');
  include('func.php');</pre>
<p>and the rest of the page.</p>
<pre class="brush:php">//jquery framework
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"><!--mce:0--></script></pre>
<pre class="brush:js">$(document).ready(function() {
	$('#wait_1').hide();
	$('#drop_1').change(function(){
	  $('#wait_1').show();
	  $('#result_1').hide();
      $.get("func.php", {
		func: "drop_1",
		drop_var: $('#drop_1').val()
      }, function(response){
        $('#result_1').fadeOut();
        setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
      });
    	return false;
	});
});

function finishAjax(id, response) {
  $('#wait_1').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}</pre>
<pre class="brush:php">
<form method="post">
<select id="drop_1" name="drop_1">
<option disabled="disabled" selected="selected">Select a Category</option>
</select>

    <span id="wait_1" style="display: none;">
    <img src="ajax-loader.gif" alt="Please Wait" />
    </span>
</form>
</pre>
<p>Ok, that was easy enough. Now for the functions <strong><em>func.php</em></strong></p>
<pre class="brush:php">//**************************************
//     Page load dropdown results     //
//**************************************
function getTierOne()
{
	$result = mysql_query("SELECT DISTINCT tier_one FROM two_drops")
	or die(mysql_error());

	  while($tier = mysql_fetch_array( $result )) 

		{
		   echo ''.$tier['tier_one'].'';
		}

}

//**************************************
//     First selection results     //
//**************************************
if($_GET['func'] == "drop_1" &amp;&amp; isset($_GET['func'])) {
   drop_1($_GET['drop_var']);
}

function drop_1($drop_var)
{
    include_once('db.php');
	$result = mysql_query("SELECT * FROM two_drops WHERE tier_one='$drop_var'")
	or die(mysql_error());

	echo '
<select id="tier_two" name="tier_two">
<option disabled="disabled" selected="selected" value=" ">Choose one</option>
<option value="'.$drop_2['tier_two'].'">'.$drop_2['tier_two'].'</option>
</select>

 ';
    echo '
<input name="submit" type="submit" value="Submit" />';
}</pre>
<p>And thats it. Download the files below.</p>
<p><a href="http://blueicestudios.com/chained-select-boxes/" target="_blank">DEMO</a></p>
<p><a href="http://blueicestudios.com/chained-select-boxes/chained_select.zip">DOWNLOAD</a></p>
<p>Want more helpful and free scripts? Buy me a cup of coffee to keep me goin!</p>
<p><a href='http://www.pledgie.com/campaigns/14423'><img alt='Click here to lend your support to: Chained Select Generator and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/14423.png?skin_name=chrome' border='0' /></a><!--more--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blueicestudios.com/chained-select-boxes-using-php-mysql-ajax/feed/</wfw:commentRss>
		<slash:comments>137</slash:comments>
		</item>
	</channel>
</rss>

