Hello @smorici,
Let’s say you have a form with the ID 123 and a form tag like this:
[select your-options id:your-options "Option 1" "Option 2" "Option 3"]
Note the form tag above has the ID your-options. We’ll use this field ID and the Form ID as selectors in the following JavaScript code snippet to redirect the user according to the option selected (you can paste this code at the end of your Form tab content):
<script type="text/javascript">
document.addEventListener('wpcf7mailsent', function (event) {
if ('123' == event.detail.contactFormId) {
var your_options = document.getElementById("your-options").value;
if (your_options == "Option 1") {
location = 'http://contactform7.com/';
}
if (your_options == "Option 2") {
location = 'https://google.com/';
}
if (your_options == "Option 3") {
location = 'https://example.com/';
}
}
}, false)
</script>
In the line 3 of the code above you’ll find the form ID 123 that you need to replace with your form ID. The next line has the selector your-options, you need to replace this ID for the one from your select form tag. Finally, you need to create as many IF statements as you have options.
Best regards,
Yordan.
Hi, thanks your help!
I tried your code, but didn´t work.
On this patch
var your_options = document.getElementById(“your-options”).value;
if (your_options == “Option 1”)
(“your-options”)= a tag of field, ok?
if (your_options == “option 1”) and “option 1” is a option select of field to redirect page.
but didn´t work
-
This reply was modified 5 years ago by
Smorici.
Hello @smorici,
This code was tested and works.
Could you please share your Form tab content?
Please note you need to replace the form ID from 123 to your current form ID.
Best regards,
Yordan.
Hi, can you see my model form?
May can be where I add code? When I tested i added on end tab form after send button.
But I tought if would be on head or body?