Support » Plugin: Contact Form 7 » DOM events – Log file

  • Hello,

    We use the plugin and we want to make a log with the contents of the emails sent.

    We use Code Snippets plugin to insert PHP code blocks in our WordPress theme but when we try to write

    document.addEventListener( 'wpcf7submit', function( event ) {
      var inputs = event.detail.inputs;
     
      for ( var i = 0; i < inputs.length; i++ ) {
        if ( 'your-name' == inputs[i].name ) {
          alert( inputs[i].value );
          break;
        }
      }
    }, false );

    The code doesn’t work. The error is:

    Don’t Panic
    The code snippet you are trying to save produced a fatal error on line 1:

    syntax error, unexpected ‘)’, expecting variable (T_VARIABLE)

    Any clue how to make it work?

Viewing 1 replies (of 1 total)
  • Erik

    (@codekraft)

    ciao @johnth,

    seems you miss to wrap the javascript code into:

    ?>
        <script type="text/javascript">
          ...your javascript code...
        </script>
    <?php

    maybe this is the reason?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.