Jonathan Saveriano
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.
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!