在其他字段中使用下拉输入作为占位符 [英] Use dropdown input as placeholder in another field

查看:55
本文介绍了在其他字段中使用下拉输入作为占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于

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);
   });
});

这篇关于在其他字段中使用下拉输入作为占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆