Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Form Maker Support

    (@formmakersupport)

    Hi, @maasut!

    Thanks for posting your question!
    Unfortunately, Form Maker does not have this functionality by default.

    However, you can get this by writing a few lines of Javascript code on Form Options > Javascript tab. Please try this.

    Firstly, add these two it inside before_load() function:

    value = getParameterByName('field');
    jQuery("#hidden_id").val(value);

    Afterwards add the following code outside of all built-in functions in the editor:

    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, " "));
    }

    Let us know if this helps.
    Cheers!

    Thread Starter maasut

    (@maasut)

    Thanks!?Like this?

    // Occurs before the form is loaded
    function before_load() {
         value = getParameterByName('field');
         jQuery("#hidden_id").val(value);
    }
    
    // Occurs just before submitting  the form
    function before_submit() {
         // IMPORTANT! If you want to interrupt (stop) the submitting of the form, this function should return true. You don't need to return any value if you don't want to stop the submission.
    }
    
    // Occurs just before resetting the form
    function before_reset() {
         
    }
    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, " "));
    }

    How should be the url address? Something https://www.mywebpage.com/?id=value

    Plugin Contributor Form Maker Support

    (@formmakersupport)

    Hello, @maasut!

    The code is correct, but let me note, that instead of #hidden_id you need to place the exact ID of the select box field (e.g. #wdform_2_element3).

    You can get it from the front-end of your form, by inspecting the element.

    The URL will be generated as the following:
    https://www.mywebpage.com/?fieldname=value

    Let me know in case you have questions.
    Cheers!

    Thread Starter maasut

    (@maasut)

    Thanks for help, but not working

    // Occurs before the form is loaded
    function before_load() {
         value = getParameterByName('field');
         jQuery("#wdform_5_element54").val(value);
    }
    
    // Occurs just before submitting  the form
    function before_submit() {
         // IMPORTANT! If you want to interrupt (stop) the submitting of the form, this function should return true. You don't need to return any value if you don't want to stop the submission.
    }
    
    // Occurs just before resetting the form
    function before_reset() {
         
    }
    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, " "));
    }
    

    Now the dropdown are unselected.Sorry my bad english.

    • This reply was modified 7 years, 2 months ago by maasut.
    Thread Starter maasut

    (@maasut)

    When I use the https://www.mywebpage.com/?fieldname=value the dropdown field are empty.

    Plugin Contributor Form Maker Support

    (@formmakersupport)

    Hi, @maasut!

    Sorry, that’s my mistake. Since the name of the parameter in the following line is field:
    value = getParameterByName('field');

    You will need to have the URL with the following format:
    https://www.mywebpage.com/?field=value

    Or you can set it to any text, but these two strings need to match. Hope this helps.
    Cheers!

    Thread Starter maasut

    (@maasut)

    Thank′s is working but these fields have conditional behaviors but are not working at the time of loading the page please look this link https://www.earth.ac.cr/en/study-at-earth/short-term-international-programs/rai-program-application/?field=Spanish_Learning_Courses and again thank you for help.

    Plugin Contributor Form Maker Support

    (@formmakersupport)

    Hey, @maasut!

    That’s a little strange, could we have a look at this problem? Please contact our team through this form and send the link to this forum thread.

    Our development team will check the issue as soon as possible, and we’ll share the solution here as well.

    Thanks! Have a good day!

    Plugin Contributor Form Maker Support

    (@formmakersupport)

    Hi, @maasut!

    I am happy to inform you, that our development team has resolved the problem on your website. They have commented the following part in Form Options > Javascript:

    value = getParameterByName("field");
    jQuery("#wdform_5_element54").val(value);

    and added the code below to /form-maker/frontend/views/FMViewForm_maker.php instead:

    jQuery(document).ready(function () {
        value = getParameterByName("field");
        jQuery("#wdform_5_element54").val(value);
    }

    Could you have a look? Please test and confirm if the problem is fixed.
    Thank you! Have a great day!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Pre select dropdown option’ is closed to new replies.