在联系表 7 中显示 Id 值

Display Id value in contact form 7

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

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

在我的情况下,每个按钮都会打开一个带有表单的模式。 但是我不能 return 表单中的 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;