Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6168799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:45:04+00:00 2026-05-23T22:45:04+00:00

Instead of a submit button I have a link: <form> <a href=#> submit </a>

  • 0

Instead of a submit button I have a link:

<form>

  <a href="#"> submit </a>

</form>

Can I make it submit the form when it is clicked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:45:05+00:00Added an answer on May 23, 2026 at 10:45 pm

    The best way

    The best way is to insert an appropriate input tag:

    <input type="submit" value="submit" />
    

    The best JS way

    <form id="form-id">
      <button id="your-id">submit</button>
    </form>
    
    var form = document.getElementById("form-id");
    
    document.getElementById("your-id").addEventListener("click", function () {
      form.submit();
    });
    

    Enclose the latter JavaScript code by an DOMContentLoaded event (choose only load for backward compatiblity) if you haven’t already done so:

    window.addEventListener("DOMContentLoaded", function () {
      var form = document.... // copy the last code block!
    });
    

    The easy, not recommandable way (the former answer)

    Add an onclick attribute to the link and an id to the form:

    <form id="form-id">
    
      <a href="#" onclick="document.getElementById('form-id').submit();"> submit </a>
    
    </form>
    

    All ways

    Whatever way you choose, you have call formObject.submit() eventually (where formObject is the DOM object of the <form> tag).

    You also have to bind such an event handler, which calls formObject.submit(), so it gets called when the user clicked a specific link or button. There are two ways:

    • Recommended: Bind an event listener to the DOM object.

      // 1. Acquire a reference to our <form>.
      //    This can also be done by setting <form name="blub">:
      //       var form = document.forms.blub;
      
      var form = document.getElementById("form-id");
      
      
      // 2. Get a reference to our preferred element (link/button, see below) and
      //    add an event listener for the "click" event.
      document.getElementById("your-id").addEventListener("click", function () {
        form.submit();
      });
      
    • Not recommended: Insert inline JavaScript. There are several reasons why this technique is not recommendable. One major argument is that you mix markup (HTML) with scripts (JS). The code becomes unorganized and rather unmaintainable.

      <a href="#" onclick="document.getElementById('form-id').submit();">submit</a>
      
      <button onclick="document.getElementById('form-id').submit();">submit</button>
      

    Now, we come to the point at which you have to decide for the UI element which triggers the submit() call.

    1. A button

      <button>submit</button>
      
    2. A link

      <a href="#">submit</a>
      

    Apply the aforementioned techniques in order to add an event listener.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form where i've replaced the submit button with an input (with
I am trying to use link to submit a form using the following code:
I have this: <a style=display: inline-block; width: 100px; font-weight: bold; href=javascript:submit()>Search</a> As instead of
I have a form with a simple text field and multiple submit buttons. When
I have a problem with a hidden submit button. I have an input field
I have a form inside a dialog that appears after clicking in another button.
I have a problem when I submit the form (pressing ENTER key or clicking
Instead of just filling out the form in HTML it should also be possible
I've got a model creation form in rails which I also have returning JSON
I have a HTML form, and I have a Controller Action that accepts the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.