@joshua.m.sells, you can update the script to properly handle the dropdown menu selections and redirect based on those selections. Here’s how you can do it:
1. Use the correct jQuery selector for your dropdown menu.
2. Update the `case` options with the actual values of your dropdown menu items.
Here’s the revised script based on your description:
<script>
$("#a2").on('change', function() {
switch ($(this).val()) {
case 'Blue':
window.module.lp.form.data.url= "http://www.example-blue.com";
break;
case 'Red':
window.module.lp.form.data.url= "http://www.example-red.com";
break;
// Add more cases as needed
default:
window.module.lp.form.data.url= "http://www.default-url.com";
break;
}
});
</script>
In this script:
- Replace `#a2` with the correct ID of your dropdown menu.
- Replace `'Blue'` and `'Red'` with the actual values from your dropdown options.
- Update the URLs to the ones you want to redirect to for each selection.
Make sure that the values in the `case` statements exactly match the values in your dropdown menu options.
I’m using the Smart Builder . .. . will this work with Smart Builder because I cannot seem to get it to work even when I upload the script.
@joshua.m.sells With smart builder, it won’t work. But it should work with classic builder. Why you’re using smart builder? If you need to do custom code, please use classic builder which is way more better than smart builder.
I created one in the classic builder. Here is the link: https://tax.jmsellslaw.com/facebook-retargeting/
I want to direct to different URLs depending on what they check in the checkbox (i.e. if they click “More than $100,000.” then I want to go to a different scheduling URL.
This is not working - it seems to be going to the same url in the form setting no matter what I choose.
Here is the script I am using (the URLs are just test urls right now)….the placement is “Before Body End Tag”
<script>
$("#how_much_dowill_you_owe_the_irs").on('change', function() {
switch ($(this).val()) {
case 'More than $100,000.':
window.module.lp.form.data.url= "http://www.google.com";
break;
case 'Between $15,000 and $100,000.':
window.module.lp.form.data.url= "http://www.google.com";
break;
default:
window.module.lp.form.data.url= "http://www.yahoo.com";
break;
}
});
</script>
Hi @joshua.m.sells,
Can you try this code, place (Before Body End Tag):
<script>
$('#lp-pom-form-66').submit(function(e) {
e.preventDefault(); // Prevent the default form submission
// Get the selected checkbox value
var selectedValue = $("#how_much_dowill_you_owe_the_irs").val();
// Determine the redirect URL based on the selected value
var redirectUrl;
switch (selectedValue) {
case 'More than $100,000.':
redirectUrl = "http://www.google.com";
break;
case 'Between $15,000 and $100,000.':
redirectUrl = "http://www.example.com";
break;
default:
redirectUrl = "http://www.yahoo.com";
break;
}
// Redirect to the chosen URL
window.location.href = redirectUrl;
});
</script>
If it’s doesn’t work, please reach out to me via email at mdmahinurkhan9@gmail.com or WhatsApp at +8801706000034.
Thanks
I just sent you an email. That is still not working.
Hi @joshua.m.sells, I hope we resolved the issue via email. Let me know if there’s anything else I can help with. If everything is resolved, feel free to mark this post as resolved. Thanks!
Perfect - thank you Mahin - that solution worked.