PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Echo Current Page Number

  1. I have a multi-page form.

    I would like to execute some custom JavaScript on a specific page.

    I understand that I can retrieve the current page number by following these instructions, however, I'm not sure how I can retrieve the value of the $current_page variable and echo it to the DOM so that I can check for it and execute my JavaScript.

    Posted 9 years ago on Thursday February 28, 2013 | Permalink
  2. I figured it out.

    Placing the following code in functions.php or before the wp_head() function in header.php will work:

    function run_script_on_last_page($form) {
        if (!is_admin()) {
            $current_page = rgpost('gform_source_page_number_' . $form['id']) ? rgpost('gform_source_page_number_' . $form['id']) : 1;
            if ($current_page == 9) {  //my last page
                wp_enqueue_script('custom_script', get_template_directory_uri() . '/js/custom_script.js', array('jquery'), null, true);
    add_action('gform_enqueue_scripts_63', 'run_script_on_last_page'); //form ID is 63

    Thanks Gravity Forms Support Forums!

    Posted 9 years ago on Friday March 1, 2013 | Permalink
  3. Glad you were able to figure that out. Thank you for the update.

    Posted 9 years ago on Tuesday March 5, 2013 | Permalink

This topic has been resolved and has been closed to new replies.