Support » Plugins » Contact Form 7: Custom redirect based off user dropdown selection

  • I’m trying to add a custom redirect to my form and I’m having trouble getting it to work.

    I have a form asking for donations and I want it to redirect to a different page for each selection.

    I got it to redirect to one page just fine, but getting it to redirect to a page + variable, I can’t seem to figure out.

    Here’s my form:
    <p>Type of Membership: [select membership-type id:options include_blank "$25 Fledgling" "$50 Naturalist" "$100 Guardian" "$250 Rehabiliator" "$500 Conservationist" "$1,000 Lifetime Sponsor"]</p>

    In the Additional Settings box I put this, which works:
    on_sent_ok: "alert("options"); var choice = 2; location = 'http://www.libertywildlife.net/addtocart.sc?productId=57&quantity='+choice;"

    My alert works fine, my URL redirect works fine and even adds the variable to the end as expected.

    My question, how do I change the variable based off the user’s dropdown menu selection?

Viewing 2 replies - 1 through 2 (of 2 total)
  • naturalworth

    (@naturalworth)

    libertywildlife is a Cool website. I have been trying to get my Contact form 7 to redirect to pages based on user selection, like you have on your site. I don’t know what I’m doing wrong.

    This is my page; http://www.emekayoga.com/?page_id=11

    When a user selects unique 1 or unique 2 and clicks send I would like them to be directed to different pages as is done by your websites drop down select field.

    1 question. I’m guessing “options” is the id you gave the drop down select field when you were creating it. Did you add “options” to the custom field of a page or pages you want to be shown when add to cart is click on your product page? if so, did you do it by simply typing in “option” as the name of the custom field or the value of the custom field on the page or pages?

    Question 2. I’m guessing a code placed in your Additional Settings box is what links a selected option in the drop down field to a given page. I’m guessing the code you have displayed above
    on_sent_ok: "alert("options"); var choice = 2; location = 'http://www.libertywildlife.net/addtocart.sc?productId=57&quantity='+choice;"
    is the one which worked for your website. Looking at the code you put above I’m thinking the code for my website should have the Id I assigned the drop down select field. Should it also have the “var choice = 2; location =’” and a web address after it? if so, how should the web address I put there relate to the the pages I would like selected options to be directed to?

    Last question. Did you have to make changes to your contact-form-7/scripts.js file to get the redirecting working. if you did, can you share the changes you made.

    I know these are a lot of questions. It’s because I don’t know much about coding, as you probably can tell.

    Any help/ question you can answer would be greatly helpful.
    P.S. it great what liberty wild life is doing for the animals.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Contact Form 7: Custom redirect based off user dropdown selection’ is closed to new replies.