1) Grab the right GIF animation from this amazing site: http://ajaxload.info/ and put it here: /sites/all/images/loading.gif
2) The CSS: make it so that the GIF is used when a certain class is applied to an input element
input.form-submit.loading-gif { background: url('/sites/all/images/loading.gif') 50% 1px no-repeat; }
3) The jQuery script: in your theme dir, create js/submit-loading.js which will apply the CSS class to the submit button when it is clicked
$(document).ready(function() { // preload image (new Image()).src = "/sites/all/images/loading.gif"; $(".webform-client-form").submit(function() { // select the button var $button = $(this).find("#edit-submit"); // remove the text, but persist the width of the button var $buttonWidth = $button.outerWidth(); $button.attr('value', '').width($buttonWidth); // display the loading gif and disable the button $button.addClass("loading-gif").attr('disabled','disabled'); }); });
4) Add the script only to the right page with a bit of PHP in your theme's template.php. See #2 in my article: Different ways of adding JavaScript to a page