• Hi all,

    Probably an easy question for hardcore developers, but I can’t seem to get this working.

    I have a conditional redirect in place in the additional settings box of contact form 7, which in sense does work as it should, but I am trying to pull in answers provided by the user at the time and drop in to the redirect url.

    Below is the code I have in the additional settings, which as I said does work and redirects to each domain correctly:

    on_sent_ok: " if (document.getElementById('id1').value=='Yes') {location.replace('https://www.domain1.com&[REPcode]&[telephone]')} else { location.replace('https://www.domain2.com/thankyou') } "

    So from the above, based on the question in the form with the id value of id1, if this is answered yes from the dropdown, it redirects to https://www.domain1.com&%5BREPcode%5D&%5Btelephone%5D and if answered as no redirects to https://www.domain2.com/thankyou.

    In the form itself, I have forms fields with the id’s ‘REPcode’ & ‘telephone’ which I want these passed through to the [REPcode] and [telephone] sections in the additional settings to complete the URL.

    As I said, this is probably a simple answer to most of you, but I’m struggling to find the answer. Any help is much appreciated.

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter designreaction

    (@designreaction)

    Anyone got any ideas? I’m up for suggestions to change the code entirely if I have to, but seeing as I’m so close to completing the stage, it seems a waste.

    There has to be a very basic and simple way to pull the information that the user has input.

    Any suggestions welcome.

    Thanks.

    Wayne

    Hey Designreaction,

    If you want to pass additional fields values to the URL, then you must get it from the payment provider to map then correctly. I use Paypal as my payment provider and they provide me with the fields I insert them in my url example

    on_sent_ok: “if(document.getElementById(‘paynow’) && document.getElementById(‘chessrating’).value> 2200) else if(document.getElementById(‘paylater’)) {location.replace(‘https://www.greensborochess.org/thank-you-for-your-participation’)} else {location = ‘https://www.paypal.com/?cmd=_xclick&[email protected]&currency_code=USD&amount=’+jQuery(‘#Tournamount’).val()+’&return=https://www.greensborochess.org/thank-you-for-your-participation/&rm=2&cancel_return=https://www.greensborochess.org/gcc-open-tournament-cancellation/&item_name=GCC Open Tournament&email=’+jQuery(‘#email’).val()+’&first_name=’+jQuery(‘#fname’).val()+’&last_name=’+jQuery(‘#lname’).val()+’ ‘;}”

    My “else if” condition is not working, I need to work on it. You can use this as an example to create your own. The rest of the code is fine. Look carefully how I had put all the fields that my form provides. You should discuss this with your payment provided. I use “Jquery” which is supported by Contact Form.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Contact Form 7 – Additional Settings – conditional redirect values’ is closed to new replies.