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 6880467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:58:40+00:00 2026-05-27T04:58:40+00:00

I have page main.html in it i have this code in the body tag:

  • 0

I have page main.html in it i have this code in the body tag:

   <form method="post">
   <p>Username: <input type="text" id="txt1" /></p>
   <p>Password: <input type="password" id="pwd1" /><br/></p>     
      <p>
          <input onclick ="checkAdmin()" class = "login_button" type="submit" 
          name="btn1" value="Login" />
       </p>
   </form>

in outer .js file:
function checkAdmin()
{

document.getElementById("private_content").style.visibility="visible";

}

in the css file i have:

 .private_content {
         visibility: hidden
  }

i want to change the visibility to visibility when the user click on Login button.
the problem is when i click on the login button the private part is visible for one moment and then disappear.

BTW is there a list of all the common JavaScript functions? i didn’t find a good one for
beginning with??

EDIT- the following code worked for me:

it looks much nicer and more convinent to use jQuery here is an example that do what i wanted to do, just with the

tag, it is the same idea.

http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_hide

  function onlyHeader(){
         $("div").hide();
        $("div#login").show();
  }

$(document).ready(function(){
  onlyHeader();
  $("#login_button").click(function(){
    var user = $("#username").val();
    var pass = $("#password").val();
    var ret = checkUser(user,pass);

    if (ret) {
        $("div").show();
        $("div#login").hide();
    }

    else {

        //user is not authorized 

    }


    });

});

NOTE: You don’t validate or store the a password on client side. On the server side you check for authentication, and store only the hash of the password.

  • 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-27T04:58:41+00:00Added an answer on May 27, 2026 at 4:58 am

    I want to change the visibility to visibility when the user click on Login button.

    Do that server side. If the user is logged on then don’t show the form.

    the problem is when i click on the login button the private part is visible for one moment and then disappear.

    This is what happens:

    1. You modify the DOM so the form becomes invisible
    2. The browser submits the form (since there is no action attribute it error recovers and uses the current URI as the action). There are various ways to stop the default behaviour from happening when you attach an event handler to something, but you don’t use any of them.
    3. The browser loads a new page, identical the old one, with the DOM reset to its initial state (with the form visible)

    Once you have processed the form data (to determine if the credentials are correct and to log the user in if they are) then use the “logged in” state on the server to decide not to include the form markup in the page at all. There is no need (or benefit) to use JS here.

    BTW is there a list of all the common JavaScript functions?

    See Mozilla’s developer content

    I didn’t find a good one for beginning with??

    W3C has an introduction to web standards that includes some JS content.

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

Sidebar

Related Questions

On my main page I have this jquery code which does an ajax call
I have coded a html page as follows: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8
I have an PHP/HTML main page, in which I include different other PHP files
I am using jQuery for a simple website and have a main page 'index.html'
I'm trying to do blog application and I want main page to have this
I have this error when I try to include the tag ( http://code.google.com/p/struts2-jquery/wiki/HeadTag )
I have this code: <body onLoad=subcatSelection();> The function is inside a .js file which
I have a page (index.html) which has a frame: <html> <body> <iframe src=otherPage.html />
I have created a HTML document with following code.. <html> <head> <title>My Page</title> </head>
I'm trying to understand this bit of code: in display.php: <html> ... <body> <table>

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.