PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Cookies and drop down menus

  1. Jamie M
    Member

    Hi all,

    I've got a form that uses cookies to pre-populate the form data; all works fine. However I also need to capture a drop-down selection. How do I do this? I'm doing the following for the regular text fields:

    add_filter("gform_field_value_email", "populate_email");
    function populate_email() {
    	return $_COOKIE["gf_email"];
    }
    Posted 12 years ago on Wednesday April 4, 2012 | Permalink
  2. If what you are trying to do is pre-select the drop down choice based on the cookie value, you would do this exactly the same way. You would use the exact same filter to do this and configure the Drop Down field to be populated dynamically just like you would the Email or a Single Input field.

    You just need to make sure that the value stored in the cookie matches exactly the value of the drop down selection you want to pre-select.

    For example, I created a test form and added a Drop Down field to it. I left the choices as the default (First Choice, Second Choice, Third Choice) choices for testing purposes. I configured it so that it could be populated dynamically and gave it a parameter name of mydropdown when doing so. I can then pre-select the value dynamically using this code:

    add_filter("gform_field_value_mydropdown", "populate_mydropdown");
    function populate_mydropdown() {
    	return "Second Choice";
    }

    When that code is executed it pre-selects the drop down selection with the value "Second Choice" when the form is displayed.

    So the implementation is exactly the same. You just need to make sure that the value you are returning matches exactly the value of the drop down selection you want to pre-select.

    Posted 12 years ago on Wednesday April 4, 2012 | Permalink

This topic has been resolved and has been closed to new replies.