Translate URL parameter into dynamic field text [RESOLVED]

hi,
trying to show a field showing the textuel version of a URL parameter. A visitor will click on a certain selection and go to the form page with the URL containing e.g. “selection=A”. Conditionally filling a field Selection with “A” is easy, but I want to adjust that text as “A” is actually a short sentence. So: if URL param is A than show value in field “This is selection A”.

I can’t seem to find the answer in the community or documentation.

Hi Rene. I have a hard time imagining what that will look like. Can you share any screenshots or sketches or examples of that?

Sure, maybe my explanation was a bit unclear. So on https://casino-avond.be/tarieven-en-offerte/ you can see 4 options, if you click any of them, that selection will be prefilled in the field second from the top on the right. You can see it does so based on the URL param ?pakket=3. My question is: how would I do this with Gform? So how can I show a specific (hardcoded) text in a field based on conditional logic (?pakket=X)?

Hi Rene. I see what you mean now. That is called dynamic population and can be done in Gravity Forms. This is the method you will use:

Your parameter name is pakket. You will use that in the URL and also in the form on the second page. In the form on your second page, go to the Advanced tab for the field you want to pre-select, and check the box “allow field to be populated dynamically” and give it the parameter name of pakket

That should be all there is to it. Whatever value you send to the form in the query string will populate that field. Give it a try here:

https://gravityforms.chrishajer.com/test-enhanced-interface/?pakket=1234%20Maple%20Ave

Change the “1234 Maple Ave” to whatever you want. Let me know if you have any questions.

Hi Chris, thanks, I’m aware of that. However, it would show “3”, which is not very clear for a customer. As posted in the original question: Conditionally filling a field Selection with “A” is easy, but I want to adjust that text as “A” is actually a short sentence. So: if URL param is A than show value in field “This is selection A”.
In other words: is there a way to implement logic that “3” would show “Three of a kind” for example?
I have it in code for another older form but it’s probably something that can be done easier with Gform?

I don’t understand. It would show “3” where?

So if you would click on any of the options on https://www.casino-avond.nl/tarieven-en-offerte/ you would see that the URL contains ?pakket= and then a number, for example 3. On the form page you would see a form that has a field “het door u geselecteerde pakket” (translation: the option you selected", prefilled with the number of the parameter. I would like to implement logic: if [1] then show text [One Pair]" and "if [3] then show text [Three of a kind].
In other words, show something to the user in a form field based on the parameter but not literally the exact parameter.
Hope this is clear.

I think I understand. You will be sending a number (like 3) in the URL, and then in the form, you want to show a pre-filled field with a text string. Is that correct?

Hi Chris, exactly! :slight_smile:

Hi Rene. Take a look at the form on this page:

https://gravityforms.chrishajer.com/conditionally-show-a-field-based-on-a-query-string-value/?pakket=2

You can send these values for pakket:

  • 1
  • 2
  • 3
  • 405

If you send any other value, the text will not show. There is a different text message for each value, and that text will be stored in the entry. Will that work for you? If so, I can share the method. If not, please let me know more details of what you need to accomplish.

Hi Chris,

Thanks so much for setting this up!
I guess what I’m seeing after filling in my email is a confirmation or notification? Would it be possible to show a field with the text in the form itself? Like the sceenshot, but instead of showing “3” it would show “Three of a Kind”?

No, that is a field in the form. The form has not been submitted, so it’s not the confirmation or email notification. It’s a text field, using conditional logic to show it. The field has been made read-only and styled to look like text in the form. That text can be changed to say anything you like.

1 Like

Ah perfect! Sounds exactly like what I was looking for. Eager to learn how to do this.

Here is the export of the form:

https://gravityforms.chrishajer.com/wp-content/uploads/gravity_forms/files/gravityforms-export-2020-07-23.json

Save that to your desktop. Then go to your site, Forms > Import/Export > Import Forms. Import this json file.

Then, you can add this CSS to style the field as a read only field. You can add this CSS to your theme (or child theme) stylesheet or via the Appearance Customizer (Appearance > Customize > Additional CSS):

.gform_wrapper input[readonly='readonly'] {
	color: #999;
	border-color: transparent;
	background-color: transparent;
	cursor: not-allowed;
}

Then, embed the form in a page on your site, and load that page. You should only see the email input and the submit button. If you populate the field with the parameter name pakket and the value 1 or 2 or 3 or 405, you can see the different text fields being conditionally displayed.

If you need anything else.

1 Like

Hi Chris, I didn’t think about the Default Value at all but of course that’s the solution for showing a fixed text. Thanks a lot!

You’re welcome. I’ll leave this open in case you need to discuss anything else.

1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.