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

  • SEARCH
  • Home
  • 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 8752069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:09:45+00:00 2026-06-13T13:09:45+00:00

I wrote a simple log in page. I want to use a javascript event

  • 0

I wrote a simple log in page. I want to use a javascript event listener for the submit button. My goal in this is to improve my javascript writing with making it most efficient and clean by using an object. I chose an singleton object function since there will only be one instance of this ever. This is what I have and I was wondering a better way to write the javascript portion. I only inlcuded the html portion to give an idea of is going on:

<head>
    <link rel="stylesheet" href="css/login_main.css"></link>

</head>

<body>
    <form action="index.php" method="post">
    <div id="enter">Enter Username :<span class="blinkme">>_</span><input class="inputs" type="text" name="uname" maxlength="20" autofocus="autofocus"/></div>
    <div id="enter">Enter Password :<span class="blinkme">>_</span><input class="inputs" type="password" name="pword" maxlength="20"/></div>
    <div id="done"><a href="">[< Submit >]</a></div>
    </form>

</body>
            <script style="text/javascript" src="js/login_main.js"></script>
            </html>

localhost js # cat login_main.js

  var formStuff = function () {
          var variables = {
        done : document.getElementById("done"),
          }


        function getSubmit () {
            docuement.forms[0].submit();
        }

        return {
            submitForm: getSubmit,
                done: function () { return variables.done; },
        }
    }();

    window.onload = formStuff.done.addEventListener("click", formStuff.getSubmit, false);
  • 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-06-13T13:09:46+00:00Added an answer on June 13, 2026 at 1:09 pm

    Simply put:

    <div id="done"><a href="javascript:document.forms[0].submit()">[< Submit >]</a></div>
    

    Or (but then you should remove the <a …>):

    document.getElementById("done").addEventListener("click", function() {
      document.forms[0].submit()
    }, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a simple JavaScript page timer for a web app.
I wrote a simple log function by c++0x variadic templates, but there are templates
I wrote a very simple perl script, and now I want to make it
I wrote a small test page to grab document.referrer of users with javascript and
I used the Chrome Console to write a simple statement: console.log(4) and received the
i wrote simple 3 functions to scrape titles , description and keywords of simple
I wrote simple class that on the start it just increase the value of
I wrote simple load testing tool for testing performance of Java modules. One problem
I wrote a simple XML file and a DTD file including an entity, but
I wrote a simple function, that makes emacs add matching quotes (so when I

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.