<?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 Field Population Based on Dropdown value</title>
		<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value</link>
		<description>Gravity Support Forums Topic: Dynamic Field Population Based on Dropdown value</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 02:56:57 +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-field-population-based-on-dropdown-value" rel="self" type="application/rss+xml" />

		<item>
			<title>David Smith on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33654</link>
			<pubDate>Fri, 26 Aug 2011 15:06:12 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">33654@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;The total portion of the code should work more like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[js]
//calculate the total value of an array of values
            var total = 0;
            $(&#38;#39;#input_167_1, #input_167_2, #input_167_4&#38;#39;).each(function() {
                total += $(this).val();
            });

            jQuery(&#38;#39;#input_167_999&#38;#39;).val(total); // update 999 to the field ID you wish to update the total for&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>sascha on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33624</link>
			<pubDate>Fri, 26 Aug 2011 06:54:43 +0000</pubDate>
			<dc:creator>sascha</dc:creator>
			<guid isPermaLink="false">33624@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Just wanted to keep up to date on this. I could not subscribe to this topic without leaving some text here....
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mattbw11 on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33593</link>
			<pubDate>Thu, 25 Aug 2011 18:08:25 +0000</pubDate>
			<dc:creator>Mattbw11</dc:creator>
			<guid isPermaLink="false">33593@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Appreciate the quick replies!  &#60;/p&#62;
&#60;p&#62;(clearly) I am not very experienced with JQuery/php but just to be clear so I understand correctly.&#60;br /&#62;
would my updated code look something like this?&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
add_filter(&#38;quot;gform_pre_render_167&#38;quot;, &#38;quot;monitor_dropdown&#38;quot;);
function monitor_dropdown($form){

?&#38;gt;
    &#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;
    jQuery(document).ready(function(){

        jQuery(&#38;#39;#input_167_3&#38;#39;).bind(&#38;#39;change&#38;#39;, function()
        {
            //get selected value from drop down;
            var selectedValue = jQuery(&#38;quot;#input_167_3&#38;quot;).val();

            //populate a text field with the selected drop down value
            jQuery(&#38;quot;#input_167_1&#38;quot;).val(selectedValue);

            //add options to a drop down menu
            jQuery(&#38;#39;#dropdown_470&#38;#39;).append(&#38;#39;&#38;lt;option value=&#38;quot;option value&#38;quot;&#38;gt;  #input_9_300, #input_9_301 , #input_9_302 , #input_9_303  &#38;lt;/option&#38;gt;&#38;#39;);

            //calculate the total value of an array of values
           var total = 0;
           $.each(arr,function(&#38;quot;#input_167_1, #input_167_2, #input_167_4&#38;quot;) {
               total += this;
               });

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

return $form;
}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Which part of the code allows you to define the field that will hold the outputted value?&#60;/p&#62;
&#60;p&#62;Thanks again, this will be great if we can add this functionality to our forms!&#60;br /&#62;
Cheers
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33591</link>
			<pubDate>Thu, 25 Aug 2011 17:21:01 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">33591@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You can add options to a drop down menu like so:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[js]
jQuery(&#38;#39;#dropdown_id&#38;#39;).append(&#38;#39;&#38;lt;option value=&#38;quot;option value&#38;quot;&#38;gt;Option Name&#38;lt;/option&#38;gt;&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The option value and name can be determined by retrieving the value of whatever field you'd like to populate there.&#60;/p&#62;
&#60;p&#62;To calculate the total value of an array of values, you can do this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[js]
var total = 0;
$.each(arr,function() {
    total += this;
});&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;You can assign the total value just like you assign the value of the field in the original example.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mattbw11 on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33590</link>
			<pubDate>Thu, 25 Aug 2011 16:59:09 +0000</pubDate>
			<dc:creator>Mattbw11</dc:creator>
			<guid isPermaLink="false">33590@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I figured it would be something that easy, thank you!&#60;/p&#62;
&#60;p&#62;With my fields now populating dynamically, I wondering... Is it possible to use jQuery in a similar way to populate a dropdown menu based on values entered into a number of fields? I am using a multi-page form. I have found a similar topic in the forum but it wont quite work for us. &#60;/p&#62;
&#60;p&#62;Also, is there a way to add/subtract/mulitply/divide the value from an array of field values and then populate another field with the result?&#60;/p&#62;
&#60;p&#62;Thanks for the help with all this you guys are great!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33586</link>
			<pubDate>Thu, 25 Aug 2011 16:46:12 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">33586@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You can add as many field IDs as you want to the line that actually updates the value. For example, you could change this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;[js]
//populate a text field with the selected drop down value
jQuery(&#38;quot;#input_167_1&#38;quot;).val(selectedValue);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;to this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;[js]
//populate a text field with the selected drop down value
jQuery(&#38;quot;#input_167_1, #input_167_2, #input_167_4&#38;quot;).val(selectedValue);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;And it would update the value of all three fields.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mattbw11 on "Dynamic Field Population Based on Dropdown value"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-field-population-based-on-dropdown-value#post-33562</link>
			<pubDate>Thu, 25 Aug 2011 13:52:09 +0000</pubDate>
			<dc:creator>Mattbw11</dc:creator>
			<guid isPermaLink="false">33562@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Is is there anyway to populate multiple fields using the example below? I know I can copy and paste the script every time I want to populate another field but I was hoping to be able to shorten the amount of code.  &#60;/p&#62;
&#60;p&#62;Do you know of an easy way to add this functionality using the code below from Alex?&#60;/p&#62;
&#60;p&#62;Thanks!&#60;br /&#62;
------------------&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
add_filter(&#38;quot;gform_pre_render_167&#38;quot;, &#38;quot;monitor_dropdown&#38;quot;);
function monitor_dropdown($form){

?&#38;gt;
    &#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;
    jQuery(document).ready(function(){

        jQuery(&#38;#39;#input_167_3&#38;#39;).bind(&#38;#39;change&#38;#39;, function()
        {
            //get selected value from drop down;
            var selectedValue = jQuery(&#38;quot;#input_167_3&#38;quot;).val();

            //populate a text field with the selected drop down value
            jQuery(&#38;quot;#input_167_1&#38;quot;).val(selectedValue);
        });
    });
    &#38;lt;/script&#38;gt;
&#38;lt;?php

return $form;
}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
