Skip to main content

Hi,


I’m looking for a script which allows me to send the user to either page A or page B, depending on the value of a dropdown field. For example:


User selects that they like Apples so they go to /thank-you/apples, or user selects they like oranges so they go to /thank-you/oranges.


Does anybody have a script handy that would do this?


Thanks!

Eliot,


Here is a script that an Unbounce team member had put together. You should be able to edit your field names and get along just fine if you are comfortable with a little javascript editing.



I got this same script from Unbounce tech support, but it doesn’t seem to be working.


I’m testing on this page: https://my.caredetective.com/landing-page-test-area/


I’ve set the form confirmation to “Go to URL” and have it pointed to: https://my.caredetective.com/upsell-test/


And the JS code I added looks like this (I’m no coder, just to be clear):


image



However, at this point “Self” is not going anywhere different. Any thoughts? :-/


I have seen a few other inquiries about using this script recently. So I figured I should post the update that works in this thread. Special thanks to @Hristian for making it work!


<script>
$("#gender").live('change', function() {
switch ($(this).val()) {
case 'Male':
window.module.lp.form.data.url = "http://www.google.com";
break;
case 'Female':
window.module.lp.form.data.url = "http://www.bing.com";
break;
};
});
</script>

Can somebody please help me. I am using a script that I have used perfectly in the past but for some reason, I can not get it to work on this page. I am trying to send users to one url if the select “Yes” in the drop down and to another if the select “No” in the dropdown. Here is the scrip I am using: (I have it set to Before End Body Tag"





$("#business_bank_account").live(‘change’, function() {


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


case 'Yes':
window.module.lp.form.data.confirmData = "https://approvals.xxxxxxx.com/business-funding-thank-you/";
break;
case 'No':
window.module.lp.form.data.confirmData = "https://approvals.xxxxxxx.com/business-funding-thank-you2/";
break;

}


});


</script>




For some reason the page is ignoring the script. The field name is correct and I have it set to “go to URL” and append is checked. There is a fallback url set as well and that is always where it is taking the user. Please help


Hey @Brett_Rosenblatt,


You need to adjust your script. Take a look one post above you for an example of what you need to change (confirmData to url).


Best,

Hristian


I am using the adjusted script but it still isn’t working. Below is my script:


$("#optin1").live(‘change’, function() {


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


case 'Yes':
window.module.lp.form.data.url = "https://URL1.com";
break;
case 'No':
window.module.lp.form.data.url = "https://URL2.com";
break;

}


});


It just keeps sending me to the deafult URL set in the “Properties” section of the builder.


Hey James, could you share the link to the page this is running on?


It would be helpful to take a look. Thanks!


http://woodgroupmortgage.com/buy-a-home-waco/


Looks like your script has a typo and the console says it’s not a function.


Try pasting this into your Unbounce page…


<script>
$("#optin1").live('change', function() {
switch ($(this).val()) {
case 'Yes':
window.module.lp.form.data.url = "https://fwytrk.com/d.ashx?ckm_campaign_id=188&ckm_key=LG9TsxmdK98&ckm_bp=1";
break;
case 'No':
window.module.lp.form.data.url = "https://fwytrk.com/d.ashx?ckm_campaign_id=136&ckm_key=LG9TsxmdK98&ckm_bp=1";
break;
};
});


I hope that works. Otherwise, I dunno 🤷


It’s not working… i follow the instruction too…


Hi everybody,


As others I am trying to redirect the user based on on the option they used in a drop down menu.


However, it’s not working, it always redirects to the fallback url.


I’ve used the following options


Custom drop down menu


Name & Id is “test”


first menu choice is “taz”


second menu choicen is “zeit”


Form Confirmation is “Go to URL”


URL is “https://www.spiegel.de


Target “Same tab or window”


Append form data to url is unchecked


This is the code I have in the javascipt window:


https://paste.ofcode.org/33sbrUU4Ekb22nqt8kqJUNS


HI Johannes,


Here’s how I’m doing it on my page. Your code looks the same as mine, EXCEPT you have a semi-colon after the curly brace in the 2nd to last line… I’m no code expert, but could that be causing a problem?


My drop-down selections are as follows:


Who are you providing care for? (field is p_relation)




  • myself




  • spouse




  • parent




  • other




Depending on what they choose i send them to 2 different pages. JS below…


–Kirsti


Here’s my JS: https://paste.ofcode.org/bKkgmpZD4PS3g8eVtHfegJ



Hi, thanks for your reply. Sadly, removing the semi-colon didn’t change anything.


I am trying to get this to work as well and no matter what I tried from all these article threads nothing is working. It would be great if someone who has gotten this to work can provide complete instructions from beginning to end on how to set this up. There is a lot of conflicting information in this forum on how this should be done.


Checking in!

Has anyone figured this out?

I’ve followed this thread through and through and it’s still not working.


Can you do this on a text field using a number range?


Example:

<20 goes to url1, >20 goes to url2


Hi! Does anyone has the solution for this? I tried to copy the scripts you wrote in the conversation but it’s still not working in my page.


Thanks!


Hey @MDesign this is the latest edition that has worked. Have you tried to mimic this one?



Also, could you share your page URL so we could take a look further?


Hey, thanks for the answer!

I’m using the latest edition but still not working, don’t know why.


Hey @MDesign,


It would help if you post a link to your page. Otherwise, it’s kind of impossible to troubleshoot this for you.


Best,

Hristian


Hey guys,

I’m having trouble getting this to work too.

Could you please help?


Here’s the page I’m testing on http://www.fieldgroup.com.au/marconato-1123909091224/


Hi @davetran01,


Add jQuery (1.4.2) to your page and it should work. Just make sure the jQuery fires before the redirect script.


Best,

Hristian


A bit different from the topic, here’s a script to redirect a form submission based on a field value:


document.getElementById(‘lp-pom-button-309’).onclick = function() {

var myInput = document.getElementById(‘number_of_orders’).value

if( myInput < 10) {

window.module.lp.form.data.url = “https://url2/”;


}

else {

window.module.lp.form.data.url = “https://url1/”;

}

};


Hope that it helps someone. I am sure you could edit it to make it work with a dropdown.



Thank you!


Hello, I’m wondering if anybody can help me with this? We’ve tried everything as per this thread but still can’t get it to work. Here’s our page:


https://www.benchmarxcampaigns.com/online-design-appointment-test/


Any help would be much appreciated 🙂

Michael


Reply