<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using AJAX To Data Bind A Child Drop Down List Based On The Selected Option Of A Parent Select Control</title>
	<atom:link href="http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/</link>
	<description>ASP.NET, PHP, XML, JavaScript, DOM, Web geekery</description>
	<lastBuildDate>Mon, 02 Jan 2012 21:22:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-246</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Sun, 19 Jul 2009 16:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-246</guid>
		<description>I understand what you are asking, Allfo. What you describe is a simple AJAX request. I&#039;d be willing to assist you with your project if you were willing to make a purchase from my wish list, linked under Copyright, Attributions and Donations.</description>
		<content:encoded><![CDATA[<p>I understand what you are asking, Allfo. What you describe is a simple AJAX request. I&#8217;d be willing to assist you with your project if you were willing to make a purchase from my wish list, linked under Copyright, Attributions and Donations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allfo</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-245</link>
		<dc:creator>Allfo</dc:creator>
		<pubDate>Sun, 19 Jul 2009 15:46:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-245</guid>
		<description>Thanks Doug!

would the process still be the same if the listbox were pre-populated from a database?  what i intended was to add items to the listbox but behind the scenes (XHR) it is being saved to the db (INSERT INTO...) and queried back (SELECT...WHERE) to be displayed in the list as a new item.

i understand the onchange() events that trigger sending of data to and from the db but i don&#039;t know how to append (DOM traversal/javascript code) the values that was just added from the textbox to the current dropdown list.

Thank you.</description>
		<content:encoded><![CDATA[<p>Thanks Doug!</p>
<p>would the process still be the same if the listbox were pre-populated from a database?  what i intended was to add items to the listbox but behind the scenes (XHR) it is being saved to the db (INSERT INTO&#8230;) and queried back (SELECT&#8230;WHERE) to be displayed in the list as a new item.</p>
<p>i understand the onchange() events that trigger sending of data to and from the db but i don&#8217;t know how to append (DOM traversal/javascript code) the values that was just added from the textbox to the current dropdown list.</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-244</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Sat, 18 Jul 2009 19:09:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-244</guid>
		<description>Allfo: I posted something on this about two years ago.

http://www.dougv.com/blog/2007/01/15/dynamically-populating-a-listbox-from-a-textbox-via-javascript-dom/

FYI, if you click on the JavaScript tag to the right, you will get just about everything I&#039;ve written on DOM manipulation, and I doubt there&#039;s anything you&#039;d want to do that I have not demonstrated in some way.</description>
		<content:encoded><![CDATA[<p>Allfo: I posted something on this about two years ago.</p>
<p><a href="http://www.dougv.com/blog/2007/01/15/dynamically-populating-a-listbox-from-a-textbox-via-javascript-dom/" rel="nofollow">http://www.dougv.com/blog/2007/01/15/dynamically-populating-a-listbox-from-a-textbox-via-javascript-dom/</a></p>
<p>FYI, if you click on the JavaScript tag to the right, you will get just about everything I&#8217;ve written on DOM manipulation, and I doubt there&#8217;s anything you&#8217;d want to do that I have not demonstrated in some way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allfo</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-243</link>
		<dc:creator>Allfo</dc:creator>
		<pubDate>Sat, 18 Jul 2009 14:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-243</guid>
		<description>hi. just want to ask how to append values to dropdown list say from a textbox using ajax. for example i have a dropdown list of cities and i want to insert a new city name into the list using a input from a textbox.

thanks</description>
		<content:encoded><![CDATA[<p>hi. just want to ask how to append values to dropdown list say from a textbox using ajax. for example i have a dropdown list of cities and i want to insert a new city name into the list using a input from a textbox.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parent &#8211; Child Select Lists Revisited: Multiple Parent &#8211; Child Select Lists Via PHP, MySQL And jQuery &#187; dougv.com « The Web home of Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-242</link>
		<dc:creator>Parent &#8211; Child Select Lists Revisited: Multiple Parent &#8211; Child Select Lists Via PHP, MySQL And jQuery &#187; dougv.com « The Web home of Doug Vanderweide</dc:creator>
		<pubDate>Sun, 21 Jun 2009 18:10:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-242</guid>
		<description>[...] we have a starting point in my original parent-child select list post. We don’t need to reinvent the wheel, therefore, so much as we need to upgrade from a horse [...]</description>
		<content:encoded><![CDATA[<p>[...] we have a starting point in my original parent-child select list post. We don’t need to reinvent the wheel, therefore, so much as we need to upgrade from a horse [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parent &#8211; Child Select Lists Revisited: Validating Selected Options Via jQuery And PHP &#187; dougv.com « The Web home of Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-241</link>
		<dc:creator>Parent &#8211; Child Select Lists Revisited: Validating Selected Options Via jQuery And PHP &#187; dougv.com « The Web home of Doug Vanderweide</dc:creator>
		<pubDate>Thu, 18 Jun 2009 04:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-241</guid>
		<description>[...] received via e-mail, in response to my previous blog entry, “Using AJAX To Data Bind A Child Drop Down List Based On The Selected Option Of A Parent Select Contr...“: Would you be interested in modifying your solution in 2 ways. One would be to have it [...]</description>
		<content:encoded><![CDATA[<p>[...] received via e-mail, in response to my previous blog entry, “Using AJAX To Data Bind A Child Drop Down List Based On The Selected Option Of A Parent Select Contr&#8230;“: Would you be interested in modifying your solution in 2 ways. One would be to have it [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-240</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Tue, 12 May 2009 23:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-240</guid>
		<description>Brian, I can&#039;t see results running on your localhost.

You are getting the state codes instead of state names as a result because the values of the parent select list are the state codes, not the state names. If you want to use state names, those need to be the values of your parent select list. And if you want to use full state names as the parent values, then you need to make three changes to the script as provided.

First, you need to change the PHP that creates the parent list to use the value of the state column as the values of the parent select list&#039;s options:

[php]
while($row = mysql_fetch_array($rs)) {
	//create separator every five records
	if($i % 5 == 0) {
		echo &quot;&lt;option value=\&quot;\&quot;&gt;--------------------&lt;/option&gt;\n&quot;;
	}
	echo &quot;&lt;option&gt;$row[state]&lt;/option&gt;\n&quot;;
	$i++;
}
[/php]

Next, you need to replace the regular expression in the citylist.php &quot;helper&quot; script that checks for proper state code, with one that will ensure the statecode variable at least isn&#039;t an injection attack:

[php]
if(!preg_match(&#039;/[A-Za-z]{4,20}/&#039;, $_GET[&#039;statecode&#039;])) {
[/php]

Finally, you need to amend the query in citylist.php to select child records by the value of the state column:

[php]
if(!$rs = mysql_query(&quot;SELECT DISTINCT city FROM php_zip_code_distance WHERE state = &#039;$_GET[statecode]&#039; AND TRIM(city) != &#039;&#039; ORDER BY city LIMIT 80&quot;)) {
	$output = &quot;alert(&#039;Error getting city list from database&#039;);\n&quot;;
}
[/php]

Those three changes will allow you to capture the full name of the state from the parent select list when you post it to a PHP page.

I&#039;m glad you&#039;ve found this script useful. If you&#039;d like to send a donation for this, simply remit any amount you like via PayPal to paypal@dougv.com.</description>
		<content:encoded><![CDATA[<p>Brian, I can&#8217;t see results running on your localhost.</p>
<p>You are getting the state codes instead of state names as a result because the values of the parent select list are the state codes, not the state names. If you want to use state names, those need to be the values of your parent select list. And if you want to use full state names as the parent values, then you need to make three changes to the script as provided.</p>
<p>First, you need to change the PHP that creates the parent list to use the value of the state column as the values of the parent select list&#8217;s options:</p>
<pre class="brush: php; title: ; notranslate">
while($row = mysql_fetch_array($rs)) {
	//create separator every five records
	if($i % 5 == 0) {
		echo &quot;&lt;option value=\&quot;\&quot;&gt;--------------------&lt;/option&gt;\n&quot;;
	}
	echo &quot;&lt;option&gt;$row[state]&lt;/option&gt;\n&quot;;
	$i++;
}
</pre>
<p>Next, you need to replace the regular expression in the citylist.php &#8220;helper&#8221; script that checks for proper state code, with one that will ensure the statecode variable at least isn&#8217;t an injection attack:</p>
<pre class="brush: php; title: ; notranslate">
if(!preg_match('/[A-Za-z]{4,20}/', $_GET['statecode'])) {
</pre>
<p>Finally, you need to amend the query in citylist.php to select child records by the value of the state column:</p>
<pre class="brush: php; title: ; notranslate">
if(!$rs = mysql_query(&quot;SELECT DISTINCT city FROM php_zip_code_distance WHERE state = '$_GET[statecode]' AND TRIM(city) != '' ORDER BY city LIMIT 80&quot;)) {
	$output = &quot;alert('Error getting city list from database');\n&quot;;
}
</pre>
<p>Those three changes will allow you to capture the full name of the state from the parent select list when you post it to a PHP page.</p>
<p>I&#8217;m glad you&#8217;ve found this script useful. If you&#8217;d like to send a donation for this, simply remit any amount you like via PayPal to <a href="mailto:paypal@dougv.com">paypal@dougv.com</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-239</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Tue, 12 May 2009 21:40:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-239</guid>
		<description>Thank so much for your reply. For some reason after I submit, It looks like I am passing the state_code (example, AL instead of Alabama) and city values to my results page.

What I get in my browser:
http://localhost/test/ajax/jquery/ResultsAdv.php?state=AL&amp;city=Moody&amp;Submit=Submit


How can I instead pass on the state (full state name &quot;Alabama&quot; not AL) and city values. Did I do something wrong or is this how it was supposed to be?

Do you have a paypal donations page?

Thank you,

Brian</description>
		<content:encoded><![CDATA[<p>Thank so much for your reply. For some reason after I submit, It looks like I am passing the state_code (example, AL instead of Alabama) and city values to my results page.</p>
<p>What I get in my browser:<br />
<a href="http://localhost/test/ajax/jquery/ResultsAdv.php?state=AL&#038;city=Moody&#038;Submit=Submit" rel="nofollow">http://localhost/test/ajax/jquery/ResultsAdv.php?state=AL&#038;city=Moody&#038;Submit=Submit</a></p>
<p>How can I instead pass on the state (full state name &#8220;Alabama&#8221; not AL) and city values. Did I do something wrong or is this how it was supposed to be?</p>
<p>Do you have a paypal donations page?</p>
<p>Thank you,</p>
<p>Brian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-238</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Tue, 12 May 2009 03:21:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-238</guid>
		<description>Brian, when you post your form, whatever values are currently selected in the select lists will post. In other words, you handle form processing as you normally would. Simply direct the action of the form at whatever page will process your results.</description>
		<content:encoded><![CDATA[<p>Brian, when you post your form, whatever values are currently selected in the select lists will post. In other words, you handle form processing as you normally would. Simply direct the action of the form at whatever page will process your results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://www.dougv.com/2009/04/24/using-ajax-to-data-bind-a-child-drop-down-list-based-on-the-selected-option-of-a-parent-select-control/#comment-237</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Tue, 12 May 2009 01:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=1890#comment-237</guid>
		<description>Wow, sorry for being a noob, but I worked out my first issue. I assumed that you renamed the automatically generated primary key column to state_code for some reason. And in fact I should have renamed the column to &quot;id&quot;. Then the column &quot;state _abbreviation&quot; in the CVS file gets changed to &quot;state_code.&quot; So now the drop downs work really slick and I am getting excited. However, how do I pass my values to a result page?

My goal is to have Dealership names and addresses get displayed once a City gets selected from the dropdown list.

Thanks again,
Brian</description>
		<content:encoded><![CDATA[<p>Wow, sorry for being a noob, but I worked out my first issue. I assumed that you renamed the automatically generated primary key column to state_code for some reason. And in fact I should have renamed the column to &#8220;id&#8221;. Then the column &#8220;state _abbreviation&#8221; in the CVS file gets changed to &#8220;state_code.&#8221; So now the drop downs work really slick and I am getting excited. However, how do I pass my values to a result page?</p>
<p>My goal is to have Dealership names and addresses get displayed once a City gets selected from the dropdown list.</p>
<p>Thanks again,<br />
Brian</p>
]]></content:encoded>
	</item>
</channel>
</rss>

