Trying to pass values to a Gravity Form inside a popup – is this possible?
With the form on a page I can dynamically popuplate fields by using a query string in the url like https://www.domain.com/pageslug/?org_name=abc, where org_name is set up for that field
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:
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.
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
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.