Title: Prefill dropdown menues (Select)
Last modified: September 30, 2020

---

# Prefill dropdown menues (Select)

 *  Resolved [jodiplannes](https://wordpress.org/support/users/jodiplannes/)
 * (@jodiplannes)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/prefill-dropdown-menues-select/)
 * Is it possible to change the selection in a dropdown menue (Select) using javascript.
   
   Changing values in regular input fields like text and number fields is no problem,
   but I do not see how to change a selection.
 * I have tried editing which selection have the “current” class and simply editing
   the value shown, but to no avail.
 * Is it at all possible?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [Nithin – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport11/)
 * (@wpmudevsupport11)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/prefill-dropdown-menues-select/#post-13478712)
 * Hi [@jodiplannes](https://wordpress.org/support/users/jodiplannes/),
 * The easiest workaround would be to switch the form setting for “Design style”
   to “None” under the “Appearance” tab so that the default **select** HTML tag 
   is only used in the form so that you could easily use jQuery to select via the
   following code:
    `jQuery("#select-1-field").val('option-3');`
 * Where “option-3” would be the value of the select option.
 * Other than that by default Forminator uses the custom JQuery and adds **ul** 
   and **li** HTML tags to structure the selection dropdown menu for “Design Styles”
   other than “None”, so it would require more custom changes to make to change 
   the dropdown selection using jQuery.
 * > I have tried editing which selection have the “current” class and simply editing
   > the value shown, but to no avail.
 * The above-shared jQuery code would be the one which gets submitted, so you could
   implement that along with your existing jQuery code to see whether that helps.
 * Please do check and advise if I’m missing anything. Have a nice day ahead.
 * Kind Regards,
    Nithin
 *  Thread Starter [jodiplannes](https://wordpress.org/support/users/jodiplannes/)
 * (@jodiplannes)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/prefill-dropdown-menues-select/#post-13478870)
 * Hi, Thank you for the reply!
 * A actually just figured out a workaround using regular Javascript. I updated 
   the “select-value” and used `element.setAttribute("aria-invalid" , "false");`
   which kind of did the trick.
 *     ```
       selectField = document.getElementById('select-3-field');
       selectField.value = "some-value"
       selectField.setAttribute("aria-invalid" , "false");
       ```
   
 * Editing the visual part turned out to be more difficult however. After a lot 
   of trial and error I figured out my problem; the “forminator-value” div was not
   loaded in immediately. So to address this i set a timeout before getting these
   elements.
 * `selectField = document.getElementById('select-3-field');`
 *     ```
       setTimeout(function(){displayValue= selectField.nextSibling.getElementsByClassName('forminator-value')[0];
                                   allValues= Array.from(selectField.nextSibling.getElementsByClassName('forminator-dropdown-list')[0].childNodes);,500);
       ```
   
 * I have wasted more time on this than I would like to admit, but hopefully this
   could help someone in the future.
    -  This reply was modified 5 years, 8 months ago by [jodiplannes](https://wordpress.org/support/users/jodiplannes/).
 *  Plugin Support [Saurabh – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support7/)
 * (@wpmudev-support7)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/prefill-dropdown-menues-select/#post-13486585)
 * Hello [@jodiplannes](https://wordpress.org/support/users/jodiplannes/),
 * I’m glad you were able to find a way and resolve things on your end. Also, thank
   you for pointing out how you resolved it as that can surely be helpful to someone.
   Should you have any doubts or need any help, feel free reply here or open a fresh
   thread and we would be happy to help.
 * Thank you,
    Prathamesh Palve

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Prefill dropdown menues (Select)’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

## Tags

 * [drop-down](https://wordpress.org/support/topic-tag/drop-down/)
 * [prefill](https://wordpress.org/support/topic-tag/prefill/)
 * [select](https://wordpress.org/support/topic-tag/select/)

 * 3 replies
 * 3 participants
 * Last reply from: [Saurabh – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support7/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/prefill-dropdown-menues-select/#post-13486585)
 * Status: resolved