在其他字段中使用下拉输入作为占位符
问题描述:
Based on this threat I've managed (with special thanks to Tami) to create a dropdown menu with variable year numbers in it. Now I would like to use that chosen value of that dropdown menu as a (part of the) placeholder for another input field.
我没有运气尝试过这个
[number* ba-maanden min:1 max:12 placeholder "cf7_get_input="recent-years""]
有人知道如何做到这一点吗?
Does anyone has an idea how to get this done?
谢谢,瓦斯科(Vasco)
Thanks, Vasco
答
这未经测试,但应该可以使用.您可以将其全部内联并用< script>
和</script>
括起来,将其添加到表单本身中,或者将其添加到主题的js文件中.
This is not tested, but should work. You can either add this to your form itself by making it all inline and surrounded with <script>
and </script>
or add this to your theme's js file.
jQuery(function($) {
$('select[name="ba-maanden"]').on('change', function(){
// Assign variable $placeholder to the chosen value
let $placeholder = $(this).val();
// replace 'your-field-name' with the cf7 field name
$('input[name="your-field-name"]').attr('placeholder', $placeholder);
});
});