You are viewing limited content. For full access, please sign in.

Question

Question

URL Redirect on variable result

asked on May 8, 2018

Hello,

I would like the user to be redirected to a specific website if a variable from a checkbox is ticked and if it's not ticked they are shown the thank you message once the form is submitted.

I've tried doing this on the redirect field within the form starting message using variables and using the below javascript but both do not work.

 

$(document).ready(function () {
  $('.HS LOG input').on('change', function () {

    if ($('.HS LOG input').val() == "TRUE") {
     $ window.location.replace("http://testsite123.com");
    }
       else if ($('.HS LOG input').val() == "FALSE") {
     $ window.location.replace("http://testsite567.co.uk");
    }
      });
});

 

Can someone please help?

Kind Regards,

Andrew

0 0

Replies

replied on May 11, 2018

Hi Andrew,

First can you confirm is below what you want?

You have a form, which contains at least a checkbox field, and a redirect field. After you click submit button, if the checkbox field is ticked: check the redirect field, if it's true, the page will be redirected to "http://testsite123.com"; if the redirect field is false, the page will be redirected to "http://testsite567.co.uk". If the checkbox field is not ticked, the page will show thank you page.

If this is the case, let me show you an example. I have a form with below fields
1. Checkbox: choice 1 is the flag to indicate whether to redirect or show thank you page.
2. Single Line: refers to the redirect field, controlling which page to be redirected to. Assume if I fill in single line "true" is when the redirect field wants to go to "http://testsite123.com", if I fill in single line "false", the redirect page would be "http://testsite567.co.uk".

 

We can access the value of choice 1 for Checkbox field as {/dataset/Checkbox/choice_1}, and access the value of Single Line as {/dataset/Single_Line}.

Then put the below script in the configuration panel of the message start event (as the pic below, the pic didn't show full script).

<script>
    var checked = true;
    var unchecked = false;
    function redirect(){
        if ({/dataset/Checkbox/choice_1}) {
            if ({/dataset/Single_Line}) {
                window.location.replace("http://testsite123.com");
            } else {
                window.location.replace("http://testsite567.co.uk");
            }
        }
    }
    redirect();
</script>

 

 

Let me know if I have any misunderstanding or you need further help.
 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.