<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<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">
	<channel>
		<title>Gravity Support Forums Topic: Dynamic ajax category child dropdown</title>
		<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown</link>
		<description>Gravity Support Forums Topic: Dynamic ajax category child dropdown</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 05:11:55 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/dynamic-ajax-category-child-dropdown" rel="self" type="application/rss+xml" />

		<item>
			<title>Richard Vav on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-376124</link>
			<pubDate>Sat, 27 Jul 2013 06:36:50 +0000</pubDate>
			<dc:creator>Richard Vav</dc:creator>
			<guid isPermaLink="false">376124@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;If you still require assistance with this please open a new &#60;a href=&#34;http://www.gravityhelp.com/request-support/&#34; rel=&#34;nofollow&#34;&#62;support ticket&#60;/a&#62; or a &#60;a href=&#34;http://www.gravityhelp.com/priority-support/&#34; rel=&#34;nofollow&#34;&#62;priority support ticket&#60;/a&#62; if you are a developer license holder. Thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>downsy42 on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-348867</link>
			<pubDate>Thu, 27 Jun 2013 22:16:44 +0000</pubDate>
			<dc:creator>downsy42</dc:creator>
			<guid isPermaLink="false">348867@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;On which php page are you placing this code??
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jkirker on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-224184</link>
			<pubDate>Thu, 25 Apr 2013 15:20:10 +0000</pubDate>
			<dc:creator>jkirker</dc:creator>
			<guid isPermaLink="false">224184@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Leonardo,&#60;/p&#62;
&#60;p&#62;Did you ever get a third level working?  Please let me know.&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
John
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Leonardo Ribeiro on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-74998</link>
			<pubDate>Wed, 12 Sep 2012 16:16:26 +0000</pubDate>
			<dc:creator>Leonardo Ribeiro</dc:creator>
			<guid isPermaLink="false">74998@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
Thanks for your code, it really works! I saw on your page 3 different dropdowns working together. I'd like to see the code. I'm working on a project and need to do something like:&#60;br /&#62;
The user fills the ZipCode field and I find on a database and fill the fields State, city and Street. Can you help me with this?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jmichiels on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-70562</link>
			<pubDate>Fri, 10 Aug 2012 11:01:47 +0000</pubDate>
			<dc:creator>jmichiels</dc:creator>
			<guid isPermaLink="false">70562@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Would you post link of where this is being used?  I'd like to see it in action to determine if it fits what I need (displaying one post category only in dropdown).  thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>muops.dm on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-64372</link>
			<pubDate>Mon, 02 Jul 2012 11:15:36 +0000</pubDate>
			<dc:creator>muops.dm</dc:creator>
			<guid isPermaLink="false">64372@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Above code is almost similar to stav's except the table names and their column names. Also, I put my form ID (1) and Empty Single Line Text (4) and Empty DropDown Field (5).&#60;/p&#62;
&#60;p&#62;Allowed field(5) to be populated dynamically.&#60;/p&#62;
&#60;p&#62;Again awesome work around while Gravity Forms is not able to handle it on UI. Wish they implement it very soon to make it more handy.&#60;/p&#62;
&#60;p&#62;&#60;strong&#62;&#60;br /&#62;
Any ideas/thoughts how this can be applied on 3 dependent dropdowns???&#60;br /&#62;
&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;Cheers!!&#60;br /&#62;
Deepak
&#60;/p&#62;</description>
		</item>
		<item>
			<title>muops.dm on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-64368</link>
			<pubDate>Mon, 02 Jul 2012 11:10:05 +0000</pubDate>
			<dc:creator>muops.dm</dc:creator>
			<guid isPermaLink="false">64368@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Stav,&#60;br /&#62;
First of all thanks for your code. Putting table names and re-writing the above code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;CREATE TABLE wp_cms_5_geo_COUNTRY (
   country_id INT NOT NULL AUTO_INCREMENT,
   country_name VARCHAR(200) NOT NULL,
   PRIMARY KEY ( country_id )
);
INSERT INTO wp_cms_5_geo_COUNTRY VALUES (1, &#38;#39;India&#38;#39;),(2, &#38;#39;America&#38;#39;),(3, &#38;#39;Africa&#38;#39;);

CREATE TABLE wp_cms_5_geo_STATES (
   state_id INT NOT NULL AUTO_INCREMENT,
   state_name VARCHAR(200) NOT NULL,
   country_id INT,
   PRIMARY KEY ( state_id )
);
INSERT INTO wp_cms_5_geo_STATES VALUES (1, &#38;#39;Rajasthan&#38;#39;, 1),(2, &#38;#39;Delhi&#38;#39;, 1),(3, &#38;#39;Punjab&#38;#39;, 1),(4, &#38;#39;Washington DC&#38;#39;, 2),(5, &#38;#39;New York&#38;#39;, 2),(6, &#38;#39;Cape Town&#38;#39;, 3);&#60;/code&#62;&#60;/pre&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
//Dynamic category dropdown
add_filter(&#38;quot;gform_pre_render_1&#38;quot;, &#38;quot;monitor_single_dropdown&#38;quot;);
function monitor_single_dropdown($form){

	global $wpdb;
	$country_table = $wpdb-&#38;gt;prefix . &#38;#39;geo_COUNTRY&#38;#39;;
	$wp_nomos_search = $wpdb-&#38;gt;get_results(&#38;quot;SELECT country_ID, country_Name FROM $country_table ORDER BY country_ID ASC&#38;quot;);

	//Creating drop down item array.
	$items = array();

	//Adding nomos to the items array
	foreach ( $wp_nomos_search as $nomos ){
	$is_selected = $nomos-&#38;gt;country_Name == &#38;quot;Rendered Title&#38;quot; ? true : false;
	$items[] = array(&#38;quot;value&#38;quot; =&#38;gt; $nomos-&#38;gt;country_ID, &#38;quot;text&#38;quot; =&#38;gt; $nomos-&#38;gt;country_Name, &#38;quot;isSelected&#38;quot;=&#38;gt; $is_selected);
	}

    //Adding other... item
	$items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Other...&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;0&#38;quot;);

	 //Adding items to field id 4
	    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)

	        if($field[&#38;quot;id&#38;quot;] == 4){
	            $field[&#38;quot;type&#38;quot;] = &#38;quot;select&#38;quot;;
	            $field[&#38;quot;choices&#38;quot;] = $items;
}

?&#38;gt;
&#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;

jQuery(document).ready(function(){

	jQuery(&#38;#39;#input_1_4&#38;#39;).change(function(){
			var mainCat=jQuery(&#38;#39;#input_1_4&#38;#39;).val();

			// call ajax
			 jQuery(&#38;quot;#input_1_5&#38;quot;).empty();
				jQuery.ajax({
					url:&#38;quot;&#38;lt;?php bloginfo( &#38;#39;wpurl&#38;#39; ); ?&#38;gt;/wp-admin/admin-ajax.php&#38;quot;,
					type:&#38;#39;POST&#38;#39;,
				    data:&#38;#39;action=monitor_children_dropdown&#38;amp;main_catid=&#38;#39; + mainCat,

					 success:function(results)
						 {
	    	//	alert(results);
		       jQuery(&#38;quot;#input_1_5&#38;quot;).append(results);
								}
						   });
				  }
			);
});

&#38;lt;/script&#38;gt;

&#38;lt;?php
return $form;
}

//ajax callback function
function monitor_children_dropdown() {
if(isset($_POST[&#38;#39;main_catid&#38;#39;])) {

$parentCat=$_POST[&#38;#39;main_catid&#38;#39;];
global $wpdb;
$states_table = $wpdb-&#38;gt;prefix . &#38;#39;geo_STATES&#38;#39;;
$wp_dimos_search = $wpdb-&#38;gt;get_results(&#38;quot;SELECT state_ID, state_Name FROM $states_table WHERE country_ID=$parentCat ORDER BY state_ID ASC&#38;quot;);

              //Creating drop down item.
			  foreach ($wp_dimos_search as $dimos) {
				$option .= &#38;#39;&#38;lt;option value=&#38;quot;&#38;#39;.$dimos-&#38;gt;state_ID.&#38;#39;&#38;quot;&#38;gt;&#38;#39;;
				$option .= $dimos-&#38;gt;state_Name;
				$option .= &#38;#39;&#38;lt;/option&#38;gt;&#38;#39;;
			  }
               //	Adding other... item
			  echo &#38;#39;&#38;lt;option value=&#38;quot;0&#38;quot; selected=&#38;quot;selected&#38;quot;&#38;gt;Select...&#38;lt;/option&#38;gt;&#38;#39;.$option;
	  die();
 } // end if
}

add_action( &#38;#39;wp_ajax_nopriv_monitor_children_dropdown&#38;#39;, &#38;#39;monitor_children_dropdown&#38;#39;); //keep for people who allow post before registration
add_action( &#38;#39;wp_ajax_monitor_children_dropdown&#38;#39;, &#38;#39;monitor_children_dropdown&#38;#39;);
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>stav on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-60436</link>
			<pubDate>Fri, 25 May 2012 22:15:16 +0000</pubDate>
			<dc:creator>stav</dc:creator>
			<guid isPermaLink="false">60436@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I resolve this issue&#60;br /&#62;
If someone need dynamic category + child dropdown e.g. states + regions&#60;br /&#62;
here is the code &#60;a href=&#34;http://pastebin.com/wrXpvHgD&#34; rel=&#34;nofollow&#34;&#62;http://pastebin.com/wrXpvHgD&#60;/a&#62;&#60;br /&#62;
(gform_pre_render_2)  my form ID 2&#60;br /&#62;
(field id 28) my empty single line text converted to dropdown&#60;br /&#62;
(field id 31) my empty drop down&#60;br /&#62;
allow field to be populated dynamically&#60;/p&#62;
&#60;p&#62;Cheers!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stav on "Dynamic ajax category child dropdown"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-ajax-category-child-dropdown#post-60336</link>
			<pubDate>Thu, 24 May 2012 19:37:41 +0000</pubDate>
			<dc:creator>stav</dc:creator>
			<guid isPermaLink="false">60336@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi i need some help on how can i post selected variable from one dynamic dropdown to second one with ajax.&#60;br /&#62;
Here is my code and i need some help on how can i accomplish this.&#60;br /&#62;
Thank you.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;//Dynamic category dropdown
add_filter(&#38;quot;gform_pre_render_2&#38;quot;, &#38;quot;monitor_single_dropdown&#38;quot;);
function monitor_single_dropdown($form){

	global $wpdb;
	$nomos_table = $wpdb-&#38;gt;prefix . &#38;#39;nomous&#38;#39;;
	$wp_nomos_search = $wpdb-&#38;gt;get_results(&#38;quot;SELECT nomos_ID, nomos_Title FROM $nomos_table ORDER BY nomos_ID ASC&#38;quot;);

	//Creating drop down item array.
	$items = array();

	//Adding initial blank value.
	//$items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;&#38;quot;);

	 //Adding dimos titles to the items array
	foreach ( $wp_nomos_search as $nomostitle ){
	$is_selected = $nomostitle-&#38;gt;nomos_Title == &#38;quot;Test&#38;quot; ? true : false;
		$items[] = array(&#38;quot;value&#38;quot; =&#38;gt; $nomostitle-&#38;gt;nomos_ID, &#38;quot;text&#38;quot; =&#38;gt; $nomostitle-&#38;gt;nomos_Title, &#38;quot;isSelected&#38;quot;=&#38;gt; $is_selected);
	}

	//Adding other... item
	//$items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Other...&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;other&#38;quot;);

	 //Adding items to field id 28
	    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)

	        if($field[&#38;quot;id&#38;quot;] == 28){
	            $field[&#38;quot;type&#38;quot;] = &#38;quot;select&#38;quot;;
	            $field[&#38;quot;choices&#38;quot;] = $items;
	        }

?&#38;gt;
&#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;

jQuery(document).ready(function(){

	jQuery(&#38;#39;#input_2_28&#38;#39;).change(function(){
			var mainCat=jQuery(&#38;#39;#input_2_28&#38;#39;).val();

			// call ajax
			 jQuery(&#38;quot;#input_2_30&#38;quot;).empty();
				jQuery.ajax({
					url:&#38;quot;&#38;lt;?php bloginfo( &#38;#39;wpurl&#38;#39; ); ?&#38;gt;/wp-admin/admin-ajax.php&#38;quot;,
					type:&#38;#39;POST&#38;#39;,
				    data:&#38;#39;action=monitor_children_dropdown&#38;amp;main_catid=&#38;#39; + mainCat,

					 success:function(results)
						 {
	    	//	alert(results);
		 //   jQuery(&#38;quot;#input_2_30&#38;quot;).append(results);
								}
						   });
				  }
							);

});
&#38;lt;/script&#38;gt;

&#38;lt;?php
return $form;
}

add_filter(&#38;quot;gform_pre_render_2&#38;quot;, &#38;quot;monitor_children_dropdown&#38;quot;);

function monitor_children_dropdown($form) {
$parentCat=$_POST[&#38;#39;main_catid&#38;#39;];

global $wpdb;
$dimoi_table = $wpdb-&#38;gt;prefix . &#38;#39;dimoi&#38;#39;; 

$wp_dimostitle_search = $wpdb-&#38;gt;get_results(&#38;quot;SELECT dimos_ID, dimos_Title FROM $dimoi_table WHERE nomos_ID=$parentCat ORDER BY dimos_ID ASC&#38;quot;);

//Creating drop down item array.
$items = array();

//Adding initial blank value.
//$items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;&#38;quot;);

 //Adding dimos titles to the items array
foreach ( $wp_dimostitle_search as $dimostitle ){
$is_selected = $dimostitle-&#38;gt;dimos_Title == &#38;quot;Test&#38;quot; ? true : false;
	$items[] = array(&#38;quot;value&#38;quot; =&#38;gt; $dimostitle-&#38;gt;dimos_Title, &#38;quot;text&#38;quot; =&#38;gt; $dimostitle-&#38;gt;dimos_Title, &#38;quot;isSelected&#38;quot;=&#38;gt; $is_selected);
}

//Adding other... item
$items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Other...&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;other&#38;quot;);

 //Adding items to field id 30
    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)

        if($field[&#38;quot;id&#38;quot;] == 30){
            $field[&#38;quot;type&#38;quot;] = &#38;quot;select&#38;quot;;
            $field[&#38;quot;choices&#38;quot;] = $items;
        }

    return $form;

//return the result to the ajax post
die();
}

add_action( &#38;#39;wp_ajax_nopriv_monitor_children_dropdown&#38;#39;, &#38;#39;monitor_children_dropdown&#38;#39;); //keep for people who allow post before registration
add_action( &#38;#39;wp_ajax_monitor_children_dropdown&#38;#39;, &#38;#39;monitor_children_dropdown&#38;#39;);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
