• This has to be a frequently asked question, but I can’t find a solution anywhere: I need to redirect to 1 of 2 different urls depending on the value of a field. I haven’t seen any working methods to get the value of a field in the on_sent_ok statement. Javascript selectors don’t seem to work.

Viewing 1 replies (of 1 total)
  • Thread Starter Greg_R

    (@greg_r)

    Ok, I finally found a working JS solution here: https://stackoverflow.com/questions/25108896/contact-form-7-redirect-page-to-specific-url-based-on-drop-down-selection

    Essentially this:

    on_sent_ok: "var Iso = $("select[name=your-selection-name]").val() ; 
    if(Iso == 'your-value-1' ){ 
       location = 'your-website1-url'; 
    } 
    if(Iso == 'your-value-2' ){ 
       location = 'your-website2-url'; 
    } 
    if(Iso == 'your-value-3' ){ 
       location = 'your-website3-url'; 
    }"

    But keep in mind that formatting will not work with CF7, is has to be all on one line. There must be at least one space between each curly brace and if. Make sure the counter of Additional settings says (1), meaning it sees only one line.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect based on field value?’ is closed to new replies.