在WordPress中实施
在我的网站上有一个WordPress的下载文件的联系表,只要你填写了资料就可以下载文件,现在我想改变一下,现在联系表里有一个下拉菜单,根据下拉菜单里选择的值,相关的文件就应该下载。
例如:下拉菜单的值为:value1和value2,文件为file1和file2。
每当用户在联系表单中选择value1时,file1就会下载。
试试这个,你要根据输入值选择不同的下载成功页面就可以了。
document.addEventListener( 'wpcf7submit', function( event ) {
if ( '4765' == event.detail.contactFormId ) { // Replace 4765 with your form ID
var whatDownload = document.getElementById("selectID").value; // Replace selectID with your dropdownID
if (whatDownload === "value1") { // Value 1 is whatever one of the values you want to check for
// Redirect location for value1
location = 'http://www.example.com/page1';
} else if (whatDownload === "value2") { // Value 1 is whatever one of the values you want to check for
// Redirect location for value2
location = 'http://www.example.com/page2';
}
}
}, false )