• Resolved iantresman

    (@iantresman)


    I’m trying to populate a form text field with data in a URL variable, eg:

    www.example.com/pagename/?fieldname1="hello"

    I’ve tried a couple of options, but think I’m missing the connection between a javascript field name, and the actual field name. My page has the following shortcodes:
    [CP_CALCULATED_FIELDS_VAR name="fieldname1" from="get"][CP_CALCULATED_FIELDS id="6"]

    Do I need to add some Javascript to transfer the field value to the form, and if so, where?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @iantresman

    Calling the parameter and variable as the field to populate in the form, does not assign the value of the parameter to the field. Please, furthermore of the shortcode for the variable in the page’s content, insert into the form a “HTML Content” field with the following piece of code as its content:

    
    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
       if(typeof fieldname1 != 'undefined') 
          fbuilderjQuery('[id*="fieldname1_"]').val(fieldname1).change();
    });
    </script>
    

    and that’s all.
    Best regards.

    Thread Starter iantresman

    (@iantresman)

    Thanks for that, and an incredible quick reply! I will try it out soon.

    Perhaps it might be worth considering a code-free option to do this, an option to enable a form to pre-populate fields via URL GET variables.

    Plugin Author codepeople

    (@codepeople)

    Hello @iantresman

    Thank you very much for the suggestions.

    Best regards.

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

The topic ‘Pre-populate field with URL get variable’ is closed to new replies.