在我的网站上,我使用联系表格7将我们的价目表发送给我们的潜在客户 . 他们只需要填写他们的姓名和电子邮件 . 如果他们想要预订我们的服务,客户只需点击电子邮件中的链接,即可将其带到另一个预订表单 . 我认为要求他们填写姓名并再次发送电子邮件看起来并不是很好,所以我想知道是否有办法让它自动填充cookie或类似的东西?非常感谢提前
您可以使用此Dynamic Contact Form 7 plugin并将$ _GET超级字母输入到URL中吗?即 example.com/contact/?first="John"&last="Cena" .
example.com/contact/?first="John"&last="Cena"
我将尝试用一个例子来描述这个过程 .
假设表单的结构是:
<label>First Name: [text first_name]</label> <label>Last Name: [text last_name]</label> <label>Email: [email email]</label>
并且您希望使用作为URL参数接收的值预先填充这些字段,例如:
http://www.your-website-domain.com/page-with-the-form/?first_name=John&last_name=Doe&email=john.doe@email.com
在表单内容的末尾输入以下代码:
<script> var urlParams = new URLSearchParams(window.location.search); if(urlParams.has('first_name')) document.getElementsByName('first_name')[0].value = urlParams.get('first_name'); if(urlParams.has('last_name')) document.getElementsByName('last_name')[0].value = urlParams.get('last_name'); if(urlParams.has('email')) document.getElementsByName('email')[0].value = urlParams.get('email'); </script>
因此,完整表单的结构(在此假设情况下)将是:
<label>First Name: [text first_name]</label> <label>Last Name: [text last_name]</label> <label>Email: [email email]</label> <script> var urlParams = new URLSearchParams(window.location.search); if(urlParams.has('first_name')) document.getElementsByName('first_name')[0].value = urlParams.get('first_name'); if(urlParams.has('last_name')) document.getElementsByName('last_name')[0].value = urlParams.get('last_name'); if(urlParams.has('email')) document.getElementsByName('email')[0].value = urlParams.get('email'); </script>
就这样 .
2 回答
您可以使用此Dynamic Contact Form 7 plugin并将$ _GET超级字母输入到URL中吗?即
example.com/contact/?first="John"&last="Cena"
.我将尝试用一个例子来描述这个过程 .
假设表单的结构是:
并且您希望使用作为URL参数接收的值预先填充这些字段,例如:
http://www.your-website-domain.com/page-with-the-form/?first_name=John&last_name=Doe&email=john.doe@email.com
在表单内容的末尾输入以下代码:
因此,完整表单的结构(在此假设情况下)将是:
就这样 .