Title: Multi redirect based on value
Last modified: August 31, 2016

---

# Multi redirect based on value

 *  [bellisimos](https://wordpress.org/support/users/bellisimos/)
 * (@bellisimos)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/)
 * Hi,
 * I need help with the following, hope you can help…
 * 1. I have a dropdown menu with different options, however they have not value.
 * Can you help me add a values to CF7 –
 * <select><option value= “Botox”>Botox</option> <option value= “Dermal Fillers”
   > Dermal Fillers</option> <option value= “Semi Permanent Makeup”>Semi Permanent
   Makeup</option> <option value= “Lip Entrancement”>Lip Entrancement</option> <
   option value= “”IPL & Laser”>”IPL & Laser</option> <option value= “Other”> Other
   </option></select>
 * 2. How do I then re-direct users who submit the form to different URL’s based
   on what they select?
 * For Example,
 * if a user selects “botox” then they redirect to – Botox Thank You Page
 * if a user selects “Lip Enhancements” then they redirect to – Lip Enhancements
   Thank You Page
 * Also, is there a way to take the name (from user) in the contact form and apply
   to thank you page. For example, if John puts his name in the name field of CF7,
   can I put his name on the thank you page. the thank you page would say “thank
   you John”?
 * 3. I need to make the dropdown menu mandatory and include blank.
 * I am not an expert on php however I have an understanding. If you need to update
   any php file, please send set by set instructions on which file to select and
   what code to replace etc.
 * Cant wait to hear back from you.
 * Many Thanks
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Touda](https://wordpress.org/support/users/touda/)
 * (@touda)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-7276486)
 * I have the same question. I’ve seen at [http://contactform7.com/redirecting-to-another-url-after-submissions/](http://contactform7.com/redirecting-to-another-url-after-submissions/)
   that we can make redirections.
 * But what if they are conditional depending on values selected by the user on 
   the submitted form?
 * First thing I guessed was to try and put an `if` statement on the `on_sent_ok:"
   location = 'http://example.com/';"` but then I saw that Contact Form 7 has no
   name for forms, so we can’t do validation based on the `formname.fieldname.value
   approach`… I guess it could be done through the `forms[numberofforminthepage]`
   but it would be dangerous if new forms are added to the page in the future.
 * I think there should be an easier way to do it…
 *  [Touda](https://wordpress.org/support/users/touda/)
 * (@touda)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-7276492)
 * I’ve being doing tests like this:
 * `on_sent_ok: "if (document.forms[0]["nameofthefield"].value='Literal value of
   the option we like to catch') {location = 'http://www.ourdomain.tld/url-of-the-
   redirection-page';}"`
 * But it does not work as it should: it always jumps to that page, no matter the
   value catched by that if.
 * I’ve also tried:
    `on_sent_ok: "if (document.forms[0]["nameofthefield"].value
   ='Literal value of the option we like to catch') {location = 'http://www.ourdomain.
   tld/url-of-the-redirection-page';} else {void();}"`
 * but it this case it never goes to that page!
 * I must doing something wrong, but I can’t see what :-/
 * I hope somebody can get the correct JS code for this.
 *  [Touda](https://wordpress.org/support/users/touda/)
 * (@touda)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-7276495)
 * 😀 Typical! The problem was that logical operator in Javascript is `==`, not `
   =` (which is assignation), so…
 * `on_sent_ok: "if (document.forms[0]["nameofthefield"].value=='Literal value of
   the option we like to catch') {location = 'http://www.ourdomain.tld/url-of-the-
   redirection-page';}"`
 * will do the trick!
 * Hope this helps.
 *  [pronet2016](https://wordpress.org/support/users/pronet2016/)
 * (@pronet2016)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-7276830)
 * Thanks so much Touda, I was googling for a solution & that was exactly what I
   needed.
 * I adapted it so it would catch all other remaining options and send you to the
   main thank you page. Thought I’d share to help people out in future.
 * on_sent_ok: “if (document.forms[0][“nameofthefield”].value==’Literal value of
   the option we like to catch’) {location = ‘[http://www.ourdomain.tld/option1&#8217](http://www.ourdomain.tld/option1&#8217);;}
   else {location = ‘[http://www.ourdomain.tld/option2&#8217](http://www.ourdomain.tld/option2&#8217);;}”
 *  [Greg_R](https://wordpress.org/support/users/greg_r/)
 * (@greg_r)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-8558829)
 * I don’t see this working at all. I see a few examples of people attempting to
   use JS selectors in the Additional Settings field, but others are saying that
   because CF7 uses Ajax to submit, those values aren’t available. Does this still
   work for you?
 *  [yugaeko](https://wordpress.org/support/users/yugaeko/)
 * (@yugaeko)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-8815061)
 * How if we have 3 or more options/value?

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multi redirect based on value’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [Greg_R](https://wordpress.org/support/users/greg_r/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/multi-redirect-based-on-value/#post-8558829)
 * Status: not resolved