• 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://www.ads-software.com/plugins/contact-form-7/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I have the same question. I’ve seen at https://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 = 'https://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…

    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 = 'https://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 = 'https://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.

    ?? 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 = 'https://www.ourdomain.tld/url-of-the-redirection-page';}"

    will do the trick!

    Hope this helps.

    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 = ‘https://www.ourdomain.tld/option1&#8217;;} else {location = ‘https://www.ourdomain.tld/option2&#8217;;}”

    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

    (@yugaeko)

    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.