I need your help. I would like to redirect to a specific page due to a checkbox selection. The Form is transferred correctly, but does not redirect to the appropriate Page after submit. I have entered the Javascript code directly into Contactform 7. (see picture 1) Can you help for a moment?
Contactform 7 Shortcode and Javascript:
[checkbox Auswahl id:eauswahl use_label_element default:0 "50€" "100€" "200€" "500€"]
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '2539' == event.detail.contactFormId ) {
var aAuswahl = document.getElementById("eauswahl").value;
if (aAuswahl == "50€") {
location = 'http://localhost/dwp/danke1/';
} if else (aAuswahl == "100€") {
location = 'http://localhost/dwp/danke2/';
} if else (aAuswahl == "200€") {
location = 'http://localhost/dwp/danke3/';
} if else (aAuswahl == "500€") {
location = 'http://localhost/dwp/danke4/';
}
}
}, false )
</script>
This code worked for me. I put this in functions.php file.
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
console.log(event.detail);
if ( '2028' == event.detail.contactFormId ) {
console.log(event.detail.inputs[5].value);
if (event.detail.inputs[5].value == '2021') {
location = 'https://example.com/wp-
content/uploads/Brochure-2021.pdf';
}
if (event.detail.inputs[5].value == '2020') {
location = 'https://example.com/wp-
content/uploads/Brochure-2020.pdf';
}
}
}, false );
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.