[英]Contact Form 7 - Redirect page to specific URL based on drop-down selection
[英]Contact Form 7 Redirect Based on Drop-Down Selection
一直在网上寻找答案。 我发现的一切似乎都没有帮助。 我知道这也是完全错误的 - 我不太了解JS让它发挥作用。 任何帮助,将不胜感激。
Contact Form7下拉列表中的4个选项(在wp站点上)。 根据所选的选项,重定向到相应的paypal付款页面。
这是在WP中添加到页面的JS。
function paypalRedirect() {
if (document.getElementsByName("eventPackage")[0].selected) {
location.href = 'http://www.test1.com';}
if (document.getElementsByName("eventPackage")[1].selected) {
location.href = 'http://www.test2.com';}
if (document.getElementsByName("eventPackage")[2].selected) {
location.href = 'http://www.test3.com';}
if (document.getElementsByName("eventPackage")[3].selected) {
location.href = 'http://www.test4.com';}
};
以下是联系表7中的附加设置:
on_sent_ok: "paypalRedirect();"
一切都很好用的形式,我只是无法让重定向工作。 我在控制台中没有看到任何错误......谢谢
请记住,联系表格7将取消on_sent_ok挂钩:
注意:不再推荐使用on_sent_ok钩子的方法。 此功能计划在2017年底之前废除。( https://contactform7.com/redirecting-to-another-url-after-submissions/ )这就是为什么我们需要一个不同的DOM事件方法( https:// contactform7.com/dom-events/ )
联系表7给出了重定向的示例:
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'https://www.example.com';
}, false );
我也对如何将dom重定向与下拉选项结合起来感兴趣
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.