Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////// 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 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement