【发布时间】:2021-08-24 03:03:19
【问题描述】:
我正在将此代码用于联系表 7 中的下拉菜单:
[select* menu-student id:menustudent include_blank "Student" "Professional"]
我想如果一个选择Student,然后在提交表单后,它会重定向到学生页面,如果选择Professional,它会在提交表单后进入专业页面。
我已经使用了这里提到的这段代码。
这是我添加的代码:
<script>
inputs = event.detail.inputs;
inputs.forEach( function(el) {
if ( el.name == 'menu-student' ) {
if ( el.value == 'Student' ) {
location.href = 'https://google.com';
} else if ( el.value == 'Professional' ) {
location.href = 'https://facebook.com';
}
}
});
</script>
但它不会为我重定向。
谁能指出我哪里做错了?
我也使用了以下脚本,但没有任何结果:
document.addEventListener( 'wpcf7submit', function( event ) {
var lpLocation = document.getElementById("menustudent").value;
if (lpLocation == "Student") {
location = 'https://facebook.com/';
} else if (lpLocation == "Professional") {
location = 'https://google.com/';
}
}, false )
任何帮助表示赞赏。
【问题讨论】:
标签: contact-form-7