Advertisement
BaapJaan

Untitled

Sep 29th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. /////////////////// Frontend
  2.  
  3.  
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  5. <script>
  6. jQuery( document ).ready(function( $ ){
  7. jQuery( document ).on('submit_success', function(event, response){
  8. document.getElementById("answer").innerHTML = response.data['1'].result;
  9. });
  10. });
  11. $( document ).ready(function() {
  12. $("#form-field-a").attr("placeholder", "017xxxxxxx").val("").focus().blur();
  13. });
  14. </script>
  15. <p style="font-size:2em" id='answer'>0</p>
  16.  
  17. /////////////////// Backend
  18.  
  19. function add_two_numbers($a, $b) {
  20. $c = $a + $b;
  21. return $c;
  22. }
  23. // A send custom WebHook
  24. add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {
  25. //make sure its our form
  26. $form_name = $record->get_form_settings( 'form_name' );
  27. if ( 'Adder' !== $form_name ) {
  28. return;
  29. }
  30. $raw_fields = $record->get( 'fields' );
  31. $fields = [];
  32. foreach ( $raw_fields as $id => $field ) {
  33. $fields[ $id ] = $field['value'];
  34. }
  35. $a = $fields['a'];
  36. $b = $fields['b'];
  37. $output['result'] = add_two_numbers($a, $b);
  38.  
  39. $handler->add_response_data( true, $output );
  40. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement