联系表 7:提交时多行 javascript
Contact form 7 : multiple lines of javascript on submit
我需要使用 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 sent 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 文件,然后将其添加到(子)主题目录中的 functions.php
:
/**
* 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();"
我还没有实际测试过,所以如果开箱后不能正常工作,请发表评论。
我需要使用 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 sent 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 文件,然后将其添加到(子)主题目录中的 functions.php
:
/**
* 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();"
我还没有实际测试过,所以如果开箱后不能正常工作,请发表评论。