Using javascript:
document.forms[0].submit();
If your form has a name attribute, you can use that name instead of a numeric index:
document.forms['header_search_form'].submit();
If it has an id (like in your question), then you cannot use the forms array, but you can use:
document.getElementById('header_search_form').submit();
In either case, you can do it though JQuery as well, but you don't need to. As you can see it's just a single line of plain Javascript.
-edit-
If you have an HTML5 document you can use the non-javascript solution by A. Wolff. But remember to check browser compatibility. IE doesn't support it, for one, and your page has to have an HTML doctype.
-edit2-
To combine the two solutions and make it IE compatible, you can do something like this:
Add the form and the submit button as you would in HTML 5:
<form action="search_name.php" id="header_search_form" method="POST"> </form> <input type="submit" form="header_search_form" value="Click me">
Then add a piece of Javascript that will use the form attribute of the submit button to detect which form should be submitted.
$(document).on('click', 'input[type="submit"]', function(event){ $button =$(this); if (formId = $button.attr('form')) { event.preventDefault(); document.getElementById(formId).submit(); } });
This will perform, through Javascript (and JQuery in this implementation), the same behaviour as the form attribute should have by default in HTML5, but this way it will also work in IE or if you have a non-html5 doctype.
This snippet always overrides the behaviour, but you could also detect the browser and only override it if necessary. Maybe it will be a feature in Modernizr once, but if I understand correctly that is not currently the case.
Demo: http://jsfiddle.net/v2E3g/2/
To make it a little more generic, you might eval (I know), the onsubmit event for the form as well. This event isn't triggered when submitting through Javascript, so if you got any onsubmit event (for validation for instance), then you're going to have to do something like this:
$(document).on('click', 'input[type="submit"]', function(event){ var $button = $(this); if (formId = $button.attr('form')) { event.preventDefault(); var form = document.getElementById(formId); var canSubmit = true; // Since submitting through Javascript won't trigger the onsubmit event, // it is forged. if ($(form).attr('onsubmit')) { canSubmit = eval('(function(){' + $(form).attr('onsubmit') + '}())'); } if (canSubmit) { form.submit(); } } });
Demo: http://jsfiddle.net/v2E3g/6/