• Resolved linkshouse

    (@linkshouse)


    Hello,

    I have several forms on my website and they each forward to a different page on completion.

    I am updating the site to use the dom event and for the page above this works fine –

    add_action( ‘wp_footer’, ‘mycustom_wp_footer’ );

    function mycustom_wp_footer() {
    ?>
    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘3562’ == event.detail.contactFormId ) {
    location = ‘https://orkneyathleticclub.co.uk/payment-page-oac-10k-series-2018/&#8217;;
    }
    }, false );
    </script>
    <?php
    }

    I thought that for the other pages/forms I could just add a series of else if statements e.g.

    add_action( ‘wp_footer’, ‘mycustom_wp_footer’ );

    function mycustom_wp_footer() {
    ?>
    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘3562’ == event.detail.contactFormId ) {
    location = ‘https://orkneyathleticclub.co.uk/payment-page-oac-10k-series-2018/&#8217;;
    else if ( ‘2975’ == event.detail.contactFormId ) {
    location = ‘https://orkneyathleticclub.co.uk/another-page/&#8217;;

    }
    }, false );
    </script>
    <?php
    }

    But when I do the above neither form forwards anymore.

    Please could you advise.

    Many Thanks

    Phill

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

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

    (@pichichi)

    Not sure if this will fix it fully but the if statement needs a closing } before it can move to else.

    So that line in your broken code block should end 2018/';} and not 2018/';

    • This reply was modified 7 years ago by pichichi.
    • This reply was modified 7 years ago by pichichi.
    • This reply was modified 7 years ago by pichichi.
    Thread Starter linkshouse

    (@linkshouse)

    Doh! That fixed it.

    Thanks @pichichi

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Forward to multiple pages’ is closed to new replies.