Hello,
I want to be able to pass which value in a drop-down menu is selected through a query string. How do I go about doing this? The drop-down is a "Product" drop down, that affects the total field and then gets passed to Cart66 for processing.
Hello,
I want to be able to pass which value in a drop-down menu is selected through a query string. How do I go about doing this? The drop-down is a "Product" drop down, that affects the total field and then gets passed to Cart66 for processing.
Bump. Anybody have an answer to this one?
You can pass form field selections via the query string when a form is submitted by using the Redirect option in the Confirmation settings. Confirmation settings are one of the tabs of the Form Settings.
You would select Redirect, then set the full http:// URL to where you want to redirect to and then you would enable the query string builder and build a query string which will then be used when the redirect occurs.
Here is a screenshot showing an example:
http://dl.dropbox.com/u/185347/Slingshot/Pictures/Screen%20Shot%202011-11-28%20at%203.56.16%20PM.png
In this example when the form is submitted it is going to redirect to this URL:
And it is going to pass this as the query string:
firstname={Name (First):1.3}&lastname={Name (Last):1.6}
When the form is submitted it would redirect to here:
http://www.mysite.com/my-page?firstname=John&lastname=Doe
There are additional options for merge tags also which are in the Documentation. By default the merge tag for selection fields (drop down, radio button and checkboxes) shows the choice label. If you need to return the value (if you configured a different value for the choice) you can append :value to the end of the merge tag. You can find merge tag documentation here:
Thanks for your reply Carl. I think that I need to rephrase my question!
From a link on a different page, I want to go to the form page where a dropdown box value that is part of all of the listed values in that drop down box (the ones specified in the form designer) will be pre-selected based on a query string.
Yes, you can do this by dynamically populating the field using the query string method.
- Edit the field you want to populate/set via the query string
- Select the Advanced Tab
- Select the "Allow field to be populated dynamically" option
- Give it a parameter name, the parameter name is what is used in the query string to pass the value (ex. product)
- Save your form
Now when you load the page containing the form, pass the value to the field using the query string (ex. http://mypage.com/myform?product=value.
The value must match the value that was setup for the choice you want to pre-select in a selection field like the drop down, radio button or checkbox field. So it must match one of the available options.
For non-selection fields like the Single Input field it will pre-populate that field with the value that is passed.
You can read more on dynamically populating fields, including via the query string method, here:
http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
Thanks Carl!
Now I have another issue though.
Although this seems to work (when I URL encode the string values), and the dropdown changes, the final price of my product does not reflect the change. Before I tried this, the dropdown would change the total price to reflect whichever option was chosen. The values are like so:
Label | Value | Price
MAU01 | +$1000 First Choice | $1,000.00
MAU02 | +$500 First Choice | $500.00
This is what somebody on another thread here suggested doing and it worked fine until I started passing the string of the value to the DropDown as you suggested. Even when I manually change the drop down, the price does not get changed anymore.
Thanks for any help Carl, you're the man!
We'll have to take a look at this locally and see if we can replicate this issue.
The Total displayed on the form is displayed using jQuery so that it dynamically changes, it's probably not being triggered when the value is passed via the query string. We'll take a look and if it's something that needs to be fixed in Gravity Forms, we'll get it updated.
We are planning to release Gravity Forms v1.6.2 this week so if this is a bug we'll get it included in this release.
I just did a quick test locally and wasn't able to replicate this issue. I can pass the product to the product field drop down via the query string and it updates the total as expected.
I'll have to take a look at this issue on your site where it is happening.
Send me:
- WordPress URL of the site
- WordPress admin login for the site
To my carl@rocketgenius.com email address and reference this forum post in your email and i'd be glad to take a look.
Let me know which form, which field and where the page is that you are loading this form so I know what to look at.