【问题标题】:Is there any way to auto submit gravity form according to radio button selection有没有办法根据单选按钮选择自动提交重力形式
【发布时间】:2019-09-03 06:59:58
【问题描述】:

我正在设置一个新的重力表单,当有人单击单选按钮“否”时,我需要在其中获得自动表单提交触发器。

这是我的表格 - https://wpskillguru.com/test/

我在主题的“function.php”文件中添加了以下代码

 add_filter( 'gchoice_22_1_1', 'add_onclick', 10, 2 );
function add_onclick( $button, $form, $radio ) {
    jQuery(document).ready(function(){

    jQuery('form#gform_22_1_1').trigger('gform_submit_button_22');

});           

但不知道如何在单选按钮中设置“onclick事件”

有没有人可以帮助我?

【问题讨论】:

    标签: javascript jquery wordpress gravity-forms-plugin


    【解决方案1】:

    您可以使用 .on() 方法并附加事件处理程序。你可以阅读更多关于它here

    $(".ginput_container_radio").on("click", "input[value='No']", function(){
         alert("No select!");
         // your code here
    });
    

    或

    $(".ginput_container_radio").on("change", "input[value='No']", function(){
             alert("No select!");
             // your code here
    });
    

    注意:ginput_container_radio 取自https://wpskillguru.com/test的单选按钮

    【讨论】:

    • 感谢您的回复,您能告诉我应该将上面的代码粘贴到我的主题中的哪里吗?这是我的重力表单字段截图 - prntscr.com/p1353j
    • 添加我的代码后能否请您给我一个“最终代码”,并发送一个 onclick 代码以插入“重力单选按钮”字段
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-02
    • 2019-09-09
    • 1970-01-01
    • 1970-01-01
    • 2021-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多