javascript - 在联系表单 7 中显示 ID 值

标签 javascript wordpress contact-form contact-form-7

我需要帮助。 我有下面的代码:脚本返回每个按钮的 id。

之后,我需要在 Wordpress 中的联系表单 7 生成的表单中返回所选的 id 值。

在我的情况下,每个按钮都会打开一个带有表单的模式。 但我无法返回表单中的 id...

function getId(myId)
{
document.getElementById("recupTitle").textContent = myId.id;
}
<ul>
<li><button id="1" onclick="getId(this);">Click the button 1</button></li>
<li><button id="2" onclick="getId(this);">Click the button 2</button></li>
<li><button id="3" onclick="getId(this);">Click the button 3</button></li>
<li><button id="4" onclick="getId(this);">Click the button 4</button></li>
<li><button id="5" onclick="getId(this);">Click the button 5</button></li>
</ul>

<p id="recupTitle"></p>

最佳答案

单击时还可以使用 id 设置表单值

document.getElementById("myField").value = myId.id;

关于javascript - 在联系表单 7 中显示 ID 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42528187/

相关文章:

php - bootstrap php 联系表单值显示错误 <br/><b>通知</b> : Undefined variable: myThema in <b>C:\x\testForm. php</b> on line <b>105</b><br/>

javascript - 当未单击某个元素时,如何对 mousedown 执行操作

javascript - Django HTML 和 CSS 呈现为 pdf

php - WordPress:自定义帖子类型,将数据发送到 "register_meta_box_cb"Arg

php - Functions.php 中的自定义函数缺少参数

validation - 自定义验证在 4.1.1 版的联系表 7 中不起作用

javascript - Web 应用程序 - iPad webkitEnterFullscreen - 以编程方式播放全屏视频

javascript - 在 Aurelia 计算中,设置依赖项时,如何声明对对象属性的依赖项

jQuery Ajax 在 iOS 中不工作(使用 list.js)

javascript - 联系表(成功提交并重置)