Add JQuery to submit button

1 0

You can filter the submit button using the gform_submit_button filter.http://www.gravityhelp.com/documentation/page/Gform_submit_button.Here is how you can use this to add Google Analytics to the submit button onclick:

add_filter("gform_submit_button_1", "add_my_value", 10, 2);
function add_my_value($button, $form) {
    $dom = new DOMDocument();
    $input = $dom->getElementsByTagName('input')->item(0);
    if ($input->hasAttribute('onclick')) {
        $input->setAttribute("onclick","_gaq.push(['_trackEvent', 'Contact', 'Information Request', 'Contact Form',, false]);".$input->getAttribute("onclick"));
    } else {
        $input->setAttribute("onclick","_gaq.push(['_trackEvent', 'Contact', 'Information Request', 'Contact Form',, false]);");
    return $dom->saveHtml();

Modify for your needs…

Leave Your Observation

Your email address will not be published. Required fields are marked *