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.

Cancel link beside the submit button

  1. I'm wondering if I can add a cancel link beside the submit button without hacking the core files of GF. Is there a hook I can call? Should I use the gform_submit_button hook?

    Posted 14 years ago on Thursday April 8, 2010 | Permalink
  2. What do you want the cancel link to do? Just close a window or link to another page?

    Depending on what you want to do, you can just add a link with some jQuery.

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    
    $("#gform_wrapper_XX .gform_footer input.button").after("<a href='#' id='cancel-link'>cancel</a>");
    
    });
    </script>

    where XX is your form id. If you're already loading jQuery in your theme, you can omit the script reference.

    Test Screenshot

    Posted 14 years ago on Thursday April 8, 2010 | Permalink
  3. Thanks Kevin.

    I updated your script to work with the jQuery conflict in WordPress.

    <script type="text/javascript">
    var $j = jQuery.noConflict();
    
    $j("#gform_wrapper_XX .gform_footer input.button").after("&nbsp;&nbsp;&nbsp;<a href='#' id='cancel-link'>Cancel</a>");
    </script>
    Posted 14 years ago on Thursday April 8, 2010 | Permalink
  4. Good idea, thanks for posting the update. I left out the non-breaking spaces in my example and opted to use CSS to position the link. Either work fine I suppose..

    Posted 14 years ago on Thursday April 8, 2010 | Permalink

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