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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:25:22+00:00 2026-06-11T01:25:22+00:00

I have a aside tag in this tag I have div which holds something

  • 0

I have a “aside” tag in this tag I have “div” which holds something like a side menu. I would like this menu to display only when user is logged in. If he is not I would like to have there instead of menu a login form. I know how I can check by JavaScript if php session was made, but I don’t know how to replace all the code by other bunch of code. Here is a code:

<aside id="main_section_right">
    <div id="side_menu_div">
        <ul id="account_menu">
            <li class="current"><a href="#">Account</a></li>
            <li><a href="#">Edit Account</a></li>
            <li><a href="#">Contact</a></li>
            <li><a href="#">Help</a></li>
            <li><a href="#">Log Out</a></li>
        </ul>
    </div>
</aside>

Now if user is not logged in I would like code inside “ul” tags to change to this.

<form>
    <li><input type="text" class="form" id="username" name="usr"/></li>
    <li><input type="text" class="form" id="password" name="paw"/></li>
    <li>
        <button type="submit" class="login_button" id="login_button">
            <b>Login</b>
        </button>
    </li>
</form>

Is there any way to do it with jQuery or JavaScript? So it’s all together going to look something like this:

<script type="text/javascript">
    if (logged_in) {
        document.getElementById("side_menu_div").innerHTML = 
    } else {
        document.getElementById("side_menu_div").innerHTML =
    }
</script>

But this work only if I’m changing text, not replacing tags. Well thank you for any help.

  • 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-11T01:25:24+00:00Added an answer on June 11, 2026 at 1:25 am

    Another idea may be to combine the two elements within #side_menu_div and toggle their visibility dependent on the login status. See this jsfiddle

    <div id="side_menu_div">
      <div id="loggedin">
       <ul id="account_menu">
         <li class="current"><a href="#">Account</a></li>
         <li><a href="#">Edit Account</a></li>
         <li><a href="#">Contact</a></li>
         <li><a href="#">Help</a></li>
         <li><a href="#">Log Out</a></li>
       </ul>
      </div>
      <div id="notloggedid" class="chklogin">
       <form>
        <ul>
         <li><input type="text" class="form" id="username" name="usr"/></li>
         <li><input type="text" class="form" id="password" name="paw"/></li>
         <li><button type="submit" class="login_button" id="login_button">
                         <b>Login</b></button></li>
         </ul>  
       </form>
      </div>
    </div>
    

    function to switch display:

    function _setMenu(loginstatus){
     if (loginstatus){
        $('#loggedin').show();
        $('#notloggedin').hide();
     } else {
        $('#loggedin').hide();
        $('#notloggedin').show();
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Java EE application page, I have header.jsp, a side menu.jsp, a body.jsp
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
i have the following css code: .tag { display: inline; font-size: 10px; padding: 5px;
In Expression Engine the {edit_date} tag would not return a UNIX timestamp like {entry_date}
This question is just to clear some things up. Some things like this have
My question: I have a mysql database that consists of something like a fact
I have created java api -ported from C# to be more specific- which aside
UI crimes aside... I'd like to have a UILabel replace a UITextField after some

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.