Title: Pre select function in dropdown
Last modified: June 6, 2019

---

# Pre select function in dropdown

 *  Resolved [anhrgrt](https://wordpress.org/support/users/anhrgrt/)
 * (@anhrgrt)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/pre-select-function-in-dropdown/)
 * Hello,
 * i need the same function like in this topic [https://wordpress.org/support/topic/pre-select-dropdown-option/](https://wordpress.org/support/topic/pre-select-dropdown-option/)
 * I allready tried to put in the javascript code but it doesn’t work. I think the
   problem is that after i click on update, all the backslashs are missing in the
   code.
 * Can someone help me with this problem?

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

 *  Thread Starter [anhrgrt](https://wordpress.org/support/users/anhrgrt/)
 * (@anhrgrt)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/pre-select-function-in-dropdown/#post-11612107)
 * I solved the problem by myself. I have put the code directly in the file: /wp-
   content/uploads/form-maker-frontend/js/fm-script-1.js. Now it works perfectly.
 * thanks
 *  Thread Starter [anhrgrt](https://wordpress.org/support/users/anhrgrt/)
 * (@anhrgrt)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/pre-select-function-in-dropdown/#post-11612946)
 * Hello,
 * now i have an other question. I want to pre select two dropdown fields with an
   url. For example /?field1=test1&?field2=test2.
 * Could someone help me with the javascript code?
 *  Plugin Support [Zhanna Khachatryan](https://wordpress.org/support/users/zhannak/)
 * (@zhannak)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/pre-select-function-in-dropdown/#post-11615900)
 * Dear [@anhrgrt](https://wordpress.org/support/users/anhrgrt/),
 * Please add the below code in your Form / Form Options / Javascript Tab and it
   should work.
 *     ```
       function before_load() {
       function getParameterByName(name, url) {
       if (!url) {
           url = window.location.href;
       }
       name = name.replace(/[[]]/g, "$&");
       var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
       results = regex.exec(url);
       if (!results) return null;
       if (!results[2]) return '';
       return decodeURIComponent(results[2].replace('/+/g', " "));
       }
       jQuery("#wdform_13_element13").val(getParameterByName("field1"));
       }
       ```
   
 * Here **#wdform_13_element13** is the field where the value should be added.

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

The topic ‘Pre select function in dropdown’ is closed to new replies.

 * ![](https://ps.w.org/form-maker/assets/icon-256x256.png?rev=2068681)
 * [Form Maker by 10Web - Mobile-Friendly Drag & Drop Contact Form Builder](https://wordpress.org/plugins/form-maker/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/form-maker/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/form-maker/)
 * [Active Topics](https://wordpress.org/support/plugin/form-maker/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/form-maker/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/form-maker/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Zhanna Khachatryan](https://wordpress.org/support/users/zhannak/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/pre-select-function-in-dropdown/#post-11615900)
 * Status: resolved