• Resolved alejandroloto

    (@alejandroloto)


    I am using the plugin for my website with the idea that depending on the response that the user chooses, a submit button will appear that redirects you to one url or another. But I don’t know how to add the redirection via url to each button. And when a button appears and I click it doesn’t send anything. What could it be? Please help.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    The plugin is not intended to work like that. But there are ways to do this. The solution depends on what you need.

    If you just want to use the form to redirect people to another page without actually submitting the form, you could just add some links in the groups and style them as buttons.

    If you do need to process the form and additionally redirect conditionally, you could write your form like this:

    [radio redirect "redirect to google.com" "redirect to example.com"]
    [group google][submit "Submit and redirect to Google"][/group]
    [group example][submit "Submit and redirect to example"][/group]
    <script>
    document.addEventListener( 'wpcf7mailsent', function( event ) {
      if(jQuery('[data-id="google"]').is(':visible')) {
        location = 'https://google.com'
      } else if (jQuery('[data-id=example]').is(':visible')) {
        location = 'http://example.com/';
      }
    }, false );
    </script>

    Then add these conditions:

    show [google] if [redirect] equals "redirect to google.com"
    show [example] if [redirect] equals "redirect to example.com"

    I’ve set up a temporary link to illustrate this.
    https://conditional-fields-cf7.bdwm.be/form-tester/?hash=fc859dbd45d0d78c89a06526560803c9
    Note that the form tester does not actually send emails, so i changed wpcf7mailsent to wpcf7mailfailed. If you copy code form here, make sure to change it back to wpcf7mailsent

    Note that the last solution is kind of an anti-pattern, because you are assuming that people will submit the form by clicking a button. If they submit the form by pressing Enter, without first showing a group, no redirect will happen.

    Plugin Author Jules Colle

    (@jules-colle)

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

The topic ‘Problem with submit button’ is closed to new replies.