实现这一点的唯一方法是使用自定义脚本文件。
使用您的functions.php
文件
add_action( \'wp_enqueue_scripts\',\'register_custom_script\');
//its important to register the script, else it will not load properly.
function register_custom_script(){
wp_register_script( \'custom-cf7-script\', <url to your script file>, array( \'jquery\' ), null, true );
}
add_filter( \'do_shortcode_tag\',\'load_custom_script\', 10,3);
function load_custom_script($output, $tag, $args){
if(\'contact-form-7\' != $tag){
return $output; //not a cf7 form shortcode.
}
if(!isset($attr[\'id\']) || <yourform-id> != $attr[\'id\']){
return $output; //not your form
}
//load your custom script that you previously registered.
wp_enqueue_script( \'custom-cf7-script\');
}
在自定义脚本中,您需要执行以下操作:,
(function($){
$(document).ready(function(){
var $select = $(\'#language-drop-down\');
var $hidden = $(\'#textfield1\');
$select.on(\'change\',function(){
if("spanish"==this.value) $hidden = "/filedirectory/for/spanish/templatefile";
});
})
})(jQuery)