在其他字段中使用下拉输入作为占位符

编程入门 行业动态 更新时间:2024-10-26 16:28:28
本文介绍了在其他字段中使用下拉输入作为占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

基于我已经解决了这个威胁(特别感谢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); }); });

更多推荐

在其他字段中使用下拉输入作为占位符

本文发布于:2023-07-16 16:10:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1123426.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!