Ian Butler
Ian Butler

Reputation: 393

Fire a Javascript function after submitting a Gravity Form

I have a multi-page form where the url remains the same when moving between pages.

I am trying to change some HTML after the submit button has been clicked.

I can run this in the console and the result is as I want it.

How can I get this run after submit?

I've tried window.onload and document.onload functions but they are not working. I've also tried an onclick function but it seems moving to the next page stops this working?

var confirm = document.getElementById('gform_confirmation_message_14');
if(confirm) {
   document.getElementsByClassName("entry-title")[0].innerHTML = "PAYE Worker";
}

Thanks

Upvotes: 1

Views: 1930

Answers (2)

Ian Butler
Ian Butler

Reputation: 393

I removed the Javascript completely and created a confirmation in Gravity Forms that redirects to a new page upon submission.

Created a title for this new page "PAYE worker"

Problem solved

Upvotes: 0

numbers1311407
numbers1311407

Reputation: 34072

Perhaps the gform_page_loaded event? From the documentation it:

Fires on multi-page forms when changing pages (i.e. going to the next or previous page).

$(document).on('gform_page_loaded', function(event, form_id, current_page) {
    // do stuff
});

There are a bunch of javascript events available, and if not this one, maybe another serves your purpose, e.g. gform_post_render.

Upvotes: 2

Related Questions