javascript - 动态设置隐藏电子邮件字段的值不起作用
问题描述
使用以下代码,我试图设置两个字段,其中一个是正确设置的隐藏类型。另一个字段是隐藏在可见性中的电子邮件字段,并且没有设置。不知道为什么在设置隐藏类型时不会发生这种情况。请注意,我根据 FluentForms WordPress 插件中的条件逻辑隐藏了此电子邮件字段。此逻辑确保当基于前面字段的所有条件都为真时,此字段不会显示。
jQuery(".ff-btn-submit").click(function() {
// Retrieve the Rep name of chosen representative.
var repName = jQuery('#ff_124_dropdown option:selected').text();
// Retrieve the email address of the chosen representative
var repNameEmail = jQuery('#ff_124_dropdown option:selected').val();
// Set the hidden email field to the Representative's email address.
jQuery("input[name=email_1]").val(repNameEmail);
// Set the hidden field to the Representative's name.
jQuery("input[name=rep_name]").val(repName);
console.log(repName + '' + repNameEmail);
});
电子邮件字段的 HTML 如下所示。
<div class="ff-el-input--content"><input type="email" name="email_1" id="ff_124_email_1" class="ff-el-form-control" placeholder="Sales Representative Email" data-name="email_1" style="background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHklEQVQ4EaVTO26DQBD1ohQWaS2lg9JybZ+AK7hNwx2oIoVf4UPQ0Lj1FdKktevIpel8AKNUkDcWMxpgSaIEaTVv3sx7uztiTdu2s/98DywOw3Dued4Who/M2aIx5lZV1aEsy0+qiwHELyi+Ytl0PQ69SxAxkWIA4RMRTdNsKE59juMcuZd6xIAFeZ6fGCdJ8kY4y7KAuTRNGd7jyEBXsdOPE3a0QGPsniOnnYMO67LgSQN9T41F2QGrQRRFCwyzoIF2qyBuKKbcOgPXdVeY9rMWgNsjf9ccYesJhk3f5dYT1HX9gR0LLQR30TnjkUEcx2uIuS4RnI+aj6sJR0AM8AaumPaM/rRehyWhXqbFAA9kh3/8/NvHxAYGAsZ/il8IalkCLBfNVAAAAABJRU5ErkJggg=="); background-repeat: no-repeat; background-attachment: scroll; background-size: 16px 18px; background-position: 98% 50%;"></div>
解决方案
推荐阅读
- angular - 如何在子组件中获取 FormControl 值?
- url - 如何在博客的主题网址中添加阿拉伯字符?
- c# - 如何在非静态构造函数中覆盖 DataContextProperty 元数据
- java - 允许 Spring 访问子模块层中定义的 bean
- c - 如何在 Cobol 中打印变量名
- css - 基于最小高度 div 的 CSS div 等高
- java - 使用 Tensorflow Python 预测数组中的下一个数字
- html - 如何仅在底部创建一个带有边框和半径的 div,在另一个带有边框和半径的 div 内
- go - Golang cron 运行多次
- laravel - 错误“安装失败,正在将 ./composer.json 还原为其原始内容。”