Skip to main content

Hi everyone!  I am trying to find a way to make a conditional URL link after a form submission based on a form field and at this point my very limited knowledge of javascript blocks me. What I am trying to achieve is that if a user inputs a specific word as an answer to a single line text field , it leads to URL #1, otherwise if its anything else than that specific word, it goes to URL #2.

Lets say the word I am looking for is hello so whenever a user inputs hello (regardless of lower case/uppercase), he is redirected to a first URL after hitting the submit button and for any other answer, it leads to another webpage.  Does anyone know of a script that would work for me?

Hope my explanation is clear, thanks in advance for your help!

Hey @M-A Buiss

What you are trying to achieve is not impossible but would require some serious JS knowledge to be able to pull it off without breaking your forms. 

Here are a couple of old posts that go in to more details and should get you 50% there. 

The rest is writing the necessary JS that fits your particular use case.  


Thank you very much for your quick reply @Hristian !

My start point was a youtube tutorial I saw from Automatalot where the URL changes based on a dropdown menu selection and here is the script he used:

<script>

$("#formfieldID").on('change', function() {

  switch ($(this).val()) {

    case 'selection1':

        window.module.lp.form.data.url = "URL1";

        break;

    case 'selection2':

        window.module.lp.form.data.url = "URL2";

        break;

  }

});

</script>

I figured it was just a matter of replacing the on(‘change’… part to link it with the text input but I understand it would be a lot more complicated than this.  I guess I’ll use the dropdown menu option, thanks again for your reply!

 


 


Reply