Title: Run JavaScript on Gravity form button click
Last modified: August 28, 2022

---

# Run JavaScript on Gravity form button click

 *  [peterhalloway00](https://wordpress.org/support/users/peterhalloway00/)
 * (@peterhalloway00)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/run-javascript-on-gravity-form-button-click/)
 * I have a gravity form with a nested form in it, I want to run a javascript function
   on adding and editing and entry, is there a way to add onclick attribute using
   hooks? or any other methods.
 * some similar codes I’ve found,
    [this adds custom class](https://github.com/gravitywiz/snippet-library/blob/master/gp-nested-forms/gpnf-add-custom-classes-to-add-entry-button.php):
 *     ```
       add_filter( 'gpnf_template_args', function( $args ) {
       	if ( $args['template'] === 'nested-entries' ) {
       		$append_classes     = 'class-a class-b';
       		$args['add_button'] = str_replace( 'gpnf-add-entry', 'gpnf-add-entry ' . $append_classes, $args['add_button'] );
       	}
       	return $args;
       } );
       ```
   
 * [and this allows to customize the text:](https://github.com/gravitywiz/snippet-library/blob/master/gp-nested-forms/gpnf-change-modal-title-and-submit-button.php)
 * is there a way to combine these to run a javascript function on click?
    -  This topic was modified 3 years, 9 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).

Viewing 1 replies (of 1 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [3 years, 9 months ago](https://wordpress.org/support/topic/run-javascript-on-gravity-form-button-click/#post-15957055)
 * You’re using a commercial/premium plugin, so please use their official support
   channel. We feel they are best equipped to support their products.
 * [https://www.gravityforms.com/help/](https://www.gravityforms.com/help/)
 * **Commercial products are [not supported in these forums](https://make.wordpress.org/support/trouble/section-1-getting-started/what-is-not-supported).**

Viewing 1 replies (of 1 total)

The topic ‘Run JavaScript on Gravity form button click’ is closed to new replies.

## Tags

 * [forms](https://wordpress.org/support/topic-tag/forms/)
 * [GravityForms](https://wordpress.org/support/topic-tag/gravityforms/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/run-javascript-on-gravity-form-button-click/#post-15957055)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
