0

有没有办法从http地址填写wpcf7表单......让我们说javascript。我有一个带有 wpcf7 控件的 HTML 表单:

<span class="wpcf7-form-control-wrap text-700">
<input class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" type="text" aria-required="true" size="30" value="" name="NameText">
</span>

例如网页地址是 www.example.com/examplefrom 有没有办法通过运行类似的东西来自动填充文本字段中的文本:www.example.com/examplefrom;javascript::getElementByID....不是网络开发人员,但我需要解决这个问题...请帮助

4

1 回答 1

0

我看到你的问题是用 php 标记的。所以我会给你一个使用 php.ini 的选项。首先,您需要检查 URL 中是否有 POST 数据发送

<?php
    if($_POST) {
        // Here you should take all your data and put it into a variable or an array
        $NameText = $_POST['NameText'];
        // The URL would look something like this:
        // www.example.com/exampleform?NameText=SomeText
    }
?>

现在在 html 中,您可以检查变量是否为空,如果可用则填写文本。

<span class="wpcf7-form-control-wrap text-700">
    <input class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" type="text" aria-required="true" size="30" value="<?php echo (isset($NameText))?$NameText:''; ?>" name="NameText">
</span>

编辑:<?php echo (isset($NameText))?$NameText:''; ?>在表单字段的每个value属性中使用您要填写数据表单的 url。

请注意:这是一个简单的示例,不检查保存后的值。如果需要,您应该检查数据。但是我认为单击表单的提交按钮后会有一些安全性。所以可能不需要..

希望对你有所帮助。

于 2013-04-11T07:58:57.967 回答