BaapJaan icon

Untitled

BaapJaan | PRO | 09/29/22 05:01:15 AM UTC | 0 ⭐ | 820 👁️ | Never ⏰ | []
text |

1.21 KB

|

None

|

0 👍

/

0 👎

/////////////////// Frontend
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
    jQuery( document ).ready(function( $ ){
        jQuery( document ).on('submit_success', function(event, response){
            document.getElementById("answer").innerHTML = response.data['1'].result;
        });
    });
    $( document ).ready(function() {
        $("#form-field-a").attr("placeholder", "017xxxxxxx").val("").focus().blur();
    });
</script>
<p style="font-size:2em" id='answer'>0</p>
 /////////////////// Backend
 function add_two_numbers($a, $b) {
    $c = $a + $b;
    return $c;
}
// A send custom WebHook
add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {
    //make sure its our form
    $form_name = $record->get_form_settings( 'form_name' );
    if ( 'Adder' !== $form_name ) {
        return;
    }
    $raw_fields = $record->get( 'fields' );
    $fields = [];
    foreach ( $raw_fields as $id => $field ) {
        $fields[ $id ] = $field['value'];
    }
    $a = $fields['a'];
    $b = $fields['b'];
    $output['result'] = add_two_numbers($a, $b);
     $handler->add_response_data( true, $output );
}, 10, 2 );

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎