Contact Form 7 provides a custom DOM events so that the developer can extend more functionality of their forms. On this article we will extend the functionality of contact form 7 by redirecting to other pages base on the option selected in a form.
jQuery(document).ready(function($){ document.addEventListener( 'wpcf7mailsent', function( event ) { var get_selected = $("select[name = career]").val(); // Get the selected value if (get_selected == 'Giáo dục' || get_selected == 'Thời trang') { location ='https://hdev.ooo/'; } else{ location = 'https://hdev.ooo/blogs'; } }, false ); });
Note that the method using on_sent_ok hook was already deprecated. This function will be removed by the end this year 2017.