Viewing 5 replies - 1 through 5 (of 5 total)
  • Bel

    (@belimperial)

    Hello @stevenjc

    Thank you for reaching out!

    In this case, the available solution is custom coded JavaScript.

    You can’t use the shortcode or pass through methods as they are processed when the form is rendered, but the form is rendered when the page loads initially, not when the popup is viewed.

    So to update them based on the clicked trigger you would use JavaScript, something like this usually does the trick:


    https://gist.github.com/danieliser/e853cf76d17d14893103696574c406b2

    The code is very much the same with a few tweaks for Gravity Forms.

    Hope that helps. If your issue is resolved please take a moment to rate and review the plugin.
    If you still need help please message us directly at https://wppopupmaker.com/support/

    Thread Starter stevenjc

    (@stevenjc)

    Thanks so much for the quick response Bel (and the fantastic plugin)
    Sounds like that will do the trick for me.

    Thread Starter stevenjc

    (@stevenjc)

    I’m just not able to get this working. Even stripping back to trying to manually set a field value directly in js in the head of my page (instead of pulling from a variable) it isn’t passing it through to the form in the popup? Trying to prepopulate field #input_5_7 in the popup #pum-1386 with xyz.

    $(document).on('pumBeforeOpen', '#pum-1386', function () {
            $("#input_5_7").val("xyz");
    });

    Am I missing something basic here?
    Thanks.

    • This reply was modified 5 years, 1 month ago by stevenjc.
    • This reply was modified 5 years, 1 month ago by stevenjc.
    Thread Starter stevenjc

    (@stevenjc)

    OK to follow up I have this working ok now. For reference for anyone else here’s how I did it, didn’t need to use the info from that other example or .on(‘pumBeforeOpen’).

    Firstly I echoed out the values I wanted to pass to the form on the page

    <span class="org_name"><?php the_title();?></span>
    <span class="my_emissions"><?php echo $my_emissions; ?></span>

    Then I used some simple jquery to grab those values and insert them into the js variables and from there into the fields

    $(document).ready(function() {
    var org_name = $( ".org_name" ).text();
    var my_emissions = $( ".my_emissions" ).text();
    $("#input_5_7").val(org_name);
    $("#input_5_3").val(my_emissions);
    });

    If you’re don’t have any need to show the values on the page at all it’s even simpler, just pass the php variables directly into the js and the fields

    $(document).ready(function() {
    var org_name = '<?php echo the_title(); ?>';
    var my_emissions = '<?php echo $my_emissions; ?>';
    $("#input_5_7").val(org_name);
    $("#input_5_3").val(my_emissions);
    });
    • This reply was modified 5 years, 1 month ago by stevenjc. Reason: adding further detail
    Bel

    (@belimperial)

    Hi @stevenjc

    It’s great to hear you have sorted the values that are passed on the form. Surely, the instructions on how you have fixed the values will help the other users. Thank you for sharing this.

    Should you need our assistance in the future, please don’t hesitate to write to us or you can send us a message at https://wppopupmaker.com/support/. By the way, If you have a moment, we would very much appreciate it if you could quickly rate and review the plugin to help us spread the word.

    Thank you in advance!

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

The topic ‘populating gravity forms field via query string’ is closed to new replies.