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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:17:46+00:00 2026-06-14T12:17:46+00:00

Confused about this…So I have a button that when clicked reveals a hidden div.

  • 0

Confused about this…So I have a button that when clicked reveals a hidden div. Im trying to set a cookie onlick so that the div will show even after the page reloads but Im having no luck…

What I dont understand is how to get a value for a clicked state…

For example:

setCookie('CookieName', 'What goes here for the clicked button state value?', 'LENGTH OF COOKIE LIFE')

<html>
<head>

<script type="text/javascript" language="JavaScript">

function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
    var now = new Date();
    then = now.getTime() + (d * 24 * 60 * 60 * 1000);
    now.setTime(then);
    exp = '; expires=' + now.toGMTString();
    }
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
} // function SetCookie()

function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
    var cookiename = n+ '=';
    var cookiebegin = document.cookie.indexOf(cookiename);
    var cookieend = 0;
    if(cookiebegin > -1) {
        cookiebegin += cookiename.length;
        cookieend = document.cookie.indexOf(";",cookiebegin);
        if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
        cookiecontent = document.cookie.substring(cookiebegin,cookieend);
        }
    }
return unescape(cookiecontent);
} // function ReadCookie()
// —>
</script>


<style type="text/css">
#sub3 {
position: absolute;
left: 100px;
top: 200px;
background-color: #f1f1f1;
width: 180px;
padding: 10px;
color: black;
border: #0000cc 2px dashed;
display: none;
}
</style>

<script language="JavaScript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
</script>

</head>
<body >

<script language="JavaScript">
function clicked() {
    setVisibility(id, visibility);
    setCookie() // this calls your set cookie function
    return true;
}
</script>

<input id="input1" type=button value='Show Layer' onclick="clicked();">

<div id="sub3">Message Box</div>

</body>
</html>
  • 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-14T12:17:47+00:00Added an answer on June 14, 2026 at 12:17 pm

    Your function setVisibility(id, visibility) accept 2 attributes, you need to specify values like setVisibility('sub3', 'block') if you want to show your block.

    You nedd to pass arguments to your functions SetCookie(name, value) and GetCookie(name).

    Also you need to show your block in page load event if function GetCookie(name) returns value.

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

Sidebar

Related Questions

I'm confused about this. Most of us have been told that there isn't any
Okey so I am a bit confused about this. I have a xml that
I am really confused about this.I have set the background color of the whole
I am a bit confused about this. I have an R package that has
I am little bit confused about this statement that I read in a book
I have a question about my C++ homework. I am just confused about *this.
OK, I always get confused about this. Let's say I have this code. Public
Can we override hardware back button functionality. I am bit confused about this kindly
I have an exam tomorrow in this and I'm getting really confused about this
I'm new to PHP and confused about this bit .. When I have this

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.