You can do it with javascript. If the form is something like:
Then you can do this in javascript:
You can use the "onClick" attribute of links or buttons to invoke this code. To invoke it automatically when a page is loaded, use the "onLoad" attribute of the element: