Best done server-side (ColdFusion, ASP, PHP, etc.) In ColdFusion you can use #cgi.script_name# to get the document name that contains the form.
location.href or document.URL will have the FQDN path including document name. Be sure to access the page via FQDN or http://localhost or http://127.0.0.1. If you access it via file:\\\C:\path\to\document.htm, then I'm not sure how that will work.