Skip to content

Instantly share code, notes, and snippets.

@pmgllc
Created January 10, 2014 15:48
Show Gist options
  • Save pmgllc/8356791 to your computer and use it in GitHub Desktop.
Save pmgllc/8356791 to your computer and use it in GitHub Desktop.
It likes this one.
<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery('#Submit').click(function() {
var splitName = jQuery('#Contact0FirstName').val();
var names = splitName.split(' ');
var firstName = names.splice(0,1);
var lastName = names.join(' ');
jQuery('#Contact0FirstName').val(firstName);
jQuery('#Contact0LastName').val(lastName);
jQuery('form').submit();
return true;
});
});
</script>
@norcross
Copy link

jQuery(document).ready(function($) {
    jQuery( 'YOUR-FORM-CLASS' ).on( 'click', '#Submit', function(event) {

        var splitName   = jQuery( '#Contact0FirstName' ).val();
        var names       = splitName.split(' ');
        var firstName   = names.splice(0,1);
        var lastName    = names.join(' ');

        jQuery( '#Contact0FirstName' ).val(firstName);
        jQuery( '#Contact0LastName' ).val(lastName);
        jQuery( 'form.YOUR-FORM-CLASS' ).submit();
        return true;
    });
});

@pmgllc
Copy link
Author

pmgllc commented Jan 10, 2014

Please send an invoice for this - I'm invoicing the client for this situation.

So, the form class is .infusion-form. I have in YOUR-FORM-CLASS replaced it with the following but is the first one missing a class "." or is it assuming an id (#) instead of a class?:

@pmgllc
Copy link
Author

pmgllc commented Jan 10, 2014

add_action('wp_footer', 'form_footer_scripts', 15);
function form_footer_scripts() { ?>
    <script type="text/javascript">
        jQuery(document).ready(function($) {
    jQuery( 'infusion-form' ).on( 'click', '#Submit', function(event) {

        var splitName   = jQuery( '#inf_field_FirstName' ).val();
        var names       = splitName.split(' ');
        var firstName   = names.splice(0,1);
        var lastName    = names.join(' ');

        jQuery( '#inf_field_FirstName' ).val(firstName);
        jQuery( '#inf_field_LastName' ).val(lastName);
        jQuery( 'form.infusion-form' ).submit();
        return true;
    });
});
    </script>
<?php
}

@pmgllc
Copy link
Author

pmgllc commented Jan 10, 2014

<form accept-charset="UTF-8" action="https://rt947.infusionsoft.com/app/form/process/4b635fc4a495ba7407b473562df17c84" class="infusion-form" method="POST">
    <input name="inf_form_xid" type="hidden" value="4b635fc4a495ba7407b473562df17c84" />
    <input name="inf_form_name" type="hidden" value="Sign up for newsletter" />
    <input name="infusionsoft_version" type="hidden" value="1.29.4.53" />
    <div class="infusion-field">
        <input class="infusion-field-input-container" id="inf_field_FirstName" name="inf_field_FirstName" type="text" value="First name" onfocus="if(this.value=='First name'){this.value=''}" onblur="if(this.value==''){this.value='First name'}">
    </div>
    <div class="infusion-field">
    <input class="infusion-field-input-container" id="inf_field_Email" name="inf_field_Email" type="text" value="Email address" onfocus="if(this.value=='Email address'){this.value=''}" onblur="if(this.value==''){this.value='Email address'}">
    </div>
    <div class="infusion-submit">
        <input type="submit" value="Get Updates" id="Submit" />
    </div>
</form>

@norcross
Copy link

yep. just gotta add the form. to the beginning

add_action('wp_footer', 'form_footer_scripts', 15);
function form_footer_scripts() { ?>
    <script type="text/javascript">
        jQuery(document).ready(function($) {
    jQuery( 'form.infusion-form' ).on( 'click', '#Submit', function(event) {

        var splitName   = jQuery( '#inf_field_FirstName' ).val();
        var names       = splitName.split(' ');
        var firstName   = names.splice(0,1);
        var lastName    = names.join(' ');

        jQuery( '#inf_field_FirstName' ).val(firstName);
        jQuery( '#inf_field_LastName' ).val(lastName);
        jQuery( 'form.infusion-form' ).submit();
        return true;
    });
});
    </script>
<?php
}

@pmgllc
Copy link
Author

pmgllc commented Jan 10, 2014

Thanks. Giving it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment