Web Connection
Submit Form via Link
Gravatar is a globally recognized avatar based on your email address. Submit Form via Link
  Steve
  All
  Oct 23, 2025 @ 06:04am

Hi,
I have a basic form to edit a customer, based on the step by step example. The Save button is at the bottom of the form. It would be nice to have a Save Link at the top section of the form, next to the Customer List link.

How do I submit the form from a link on the form? Do I need to call the btnSubmit.Click() via javascript maybe?? I could not find any examples on the Message Board. Is this not recommended or feasible?

TIA,
Steve

Gravatar is a globally recognized avatar based on your email address. re: Submit Form via Link
  Rick Strahl
  Steve
  Oct 23, 2025 @ 08:29am

A form submit has to either happen inside of the <form> tag or as you suggest you have to trigger the click via JavaScript.

The latter is pretty easy:

<!-- just before </body> tag -->
<script>
document.getElementById("btnSubmit")
        .addEventListener("click", function() {
           document.getElementById("form1").submit();
        });
</script>

Actually doing some research just now I found out that there's a relatively new Html feature which allows specifying an attribute on a submit button called form that allows you to specify the id:

<!-- button outside of a form -->
<button type="submit" name="btnSubmit" id="btnSubmit" form="form1">
   Submit me
</button>

Haven't tried this myself but this should work in any modern browser.

+++ Rick ---

© 1996-2025