• Go to Formidable Forms Official Site
  •  Login
  •  

Log In

Forgot Password

Search

Formidable Forms Community Site

Jonathan Saveriano

Autopopulating Dropdown Fields with Autocomplete Enabled

When autocomplete is enabled on a dropdown field, your standard code will not work to autopopulate it.

If you insert any kind of javascript that intends to alter a dropdown field which has autocomplete enabled, the following code snippet has to be added in order for any changes to be reflected : $("select[name='item_meta[123]']").trigger("chosen:updated"); . where item meta[123] is the dropdown field which you are trying to alter.

That little snippet is required for not just conditionally selecting a default value, but also for conditionally hiding / showing certain dropdown options, etc.

Conditional Default Values for Dropdown Menus

Hey there, Has anyone had any experience setting a default value for a dropdown field (with separate labels / values) conditional upon the option selected from another dropdown? In other words, when the user selects an option from Dropdown [123], Dropdown [789] will be "autopopulated" with a value based on what was chosen in [123]. From what I have gathered, it is not a normal feature of formidable and requires custom JavaScript. I have been trying to a function with conditional statements as follows: jQuery(document).ready(function($){ $('select[name="item_meta[123]"]').change(function(){ var val1 = $("select[name='item_meta[123]']").val(); if (val1 == "Option 1") {$("select[name='item_meta[789]']").val(5);} else if (val1 == "Option 2") {$("select[name='item_meta[789]']").val(10);} $("select[name='item_meta[789]']").change(); }); }); The problem is that my dropdown menu [789] has separate labels / values. If the dropdown did not have separate values it would work perfectly. However, I cannot remove the separate values as I need them for another purpose. As it stands, no label gets selected on [789] once [123] has been changed. Any ideas? Thanks in advance!

Navigation

  • Privacy Policy
  • Formidable Forms for WordPress

Discussions

  • An add-on
  • Creating posts/pages
  • Emails
  • Entries
  • Filter & Action Hooks
  • Forms
  • Getting Started
  • Importing/Exporting
  • Javascript
  • Reports, Graphs and Statistics
  • Styles
  • Styling
  • Tips & Tricks
  • Views

Disclaimer

The purpose of this site is to help members of the Formidable Forms Community interact with one another, provide examples of custom code and help others with topics that may not be covered by support on the main Formidable Forms website. If you are seeking support from the Formidable Forms team, please create a ticket on the Formidable Forms website.

Copyright © 2021 Strategy11, LLC