本文介绍了在其他字段中使用下拉输入作为占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基于我已经解决了这个威胁(特别感谢Tami),以创建一个包含可变年份的下拉菜单.现在,我想使用该下拉菜单的选定值作为另一个输入字段的(一部分)占位符.
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); }); });更多推荐
在其他字段中使用下拉输入作为占位符
发布评论