• Resolved stroebjo

    (@stroebjo)


    I would like to access the form title and ID inside the JavaScript event [0]. You get the event variable in the callback and through the target property get the HTML id="" of the emitting form.

    Inside the form is a hidden input field with name="_wpcf7" wich contains the WordPress ID of the form. This is perfect, but I would also like to get to the name of the form.

    Is it possible to add a hidden input field like name="_wpcf7_title" that contains the title? Or is it the possible to get the name with the JavaScript another way?

    Thanks,
    Jonathan

    [0]: https://contactform7.com/dom-events/

    • This topic was modified 7 years, 10 months ago by stroebjo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You can create a hidden field in the form to pass through the title, though it would be hardcoded, not dynamic, so you’d have to create one for each form you wanted to do this for.

    The hidden field documentation mentions doing something like the following example:

    [hidden wpcf7-title "Example form title"]

    which would spit out the following:

    <input type="hidden" name="wpcf7-title" value="Example form title" class="wpcf7-form-control wpcf7-hidden">

    • This reply was modified 7 years, 10 months ago by cabrailsford.
    Thread Starter stroebjo

    (@stroebjo)

    Ah that is a great idea. I will go with that!

    Thanks for sharing!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Access Form ID / Title inside JavaScript Event Callback’ is closed to new replies.