gpt4 book ai didi

javascript - 联系表 7 : multiple lines of javascript on submit

转载 作者:行者123 更新时间:2023-12-02 13:52:45 24 4
gpt4 key购买 nike

我需要使用 Contact 7 拥有一个嵌入式表单,将信息提交到我的 Viral Loops 帐户。

提交表单后需要运行以下代码,即on_sent_ok:

VL.options.form_fields.form_firstName = $("#firstname").val(); //capture the first name
VL.options.form_fields.form_email = $("#email").val(); //capture the email
VL.options.form_fields.form_lastName = $("#lastname").val(); //capture the last name (if applicable in your form)
//submit the participant to Viral Loops
VL.createLead(function() {
//any logic to run after the participation
});

我不知道在哪里或如何添加它,因为在高级设置中只能使用一行代码使用 on send ok。

提前致谢!! :)

最佳答案

正如评论中提到的,要么缩小它:

on_sent_ok: "VL.options.form_fields.form_firstName = $('#firstname').val();VL.options.form_fields.form_email = $('#email').val();VL.options.form_fields.form_lastName = $('#lastname').val();VL.createLead(function() {});"
<小时/>

或者您可以在 js/script.js 的(子)主题目录中创建一个 JavaScript 文件,然后将其添加到 (子)主题目录:

/**
* Enqueue a script with jQuery as a dependency.
*/
function so_40916565_enqueue() {
wp_enqueue_script( 'so-40916565', get_stylesheet_directory_uri() . '/js/script.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'so_40916565_enqueue' );

在您新创建的 JavaScript 文件中:

function js_40916565() {
VL.options.form_fields.form_firstName = $("#firstname").val(); //capture the first name
VL.options.form_fields.form_email = $("#email").val(); //capture the email
VL.options.form_fields.form_lastName = $("#lastname").val(); //capture the last name (if applicable in your form)
//submit the participant to Viral Loops
VL.createLead(function() {
//any logic to run after the participation
});
}

在您的联系表 7 中:

on_sent_ok: "js_40916565();"

我还没有实际测试过它,所以如果它不能立即工作,请发表评论。

关于javascript - 联系表 7 : multiple lines of javascript on submit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40916565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com