javascript with cookeis
2 posters
Page 1 of 1
javascript with cookeis
hello , anybody tell me how I can save changes in javascript by cookeis
for example
this code in tamplate
when I click on div1 the div2 hide , ok I need this effect presist for long time .
not return to first value on refreshing the page
please I need this manner quickly
THANK YOU
for example
this code in tamplate
- Code:
$("#div1").click(function() {
$("#div2").hide();
});
when I click on div1 the div2 hide , ok I need this effect presist for long time .
not return to first value on refreshing the page
please I need this manner quickly
THANK YOU
Re: javascript with cookeis
Forumotion has the following functions installed on the forums for handling cookies.
my_setcookie : sets a cookie. For example :
my_getcookie : gets an exisiting cookie and returns its value if it has one. For example :
This is a simple example :
The script creates two elements and appends them to the body; a button and container. The button toggles the display state of the container, and the cookies handle the state whenever the page is changed.
my_setcookie : sets a cookie. For example :
- Code:
my_setcookie('cookieName', 'cookie value');
my_getcookie : gets an exisiting cookie and returns its value if it has one. For example :
- Code:
my_getcookie('cookieName'); // returns 'cookie value'
This is a simple example :
- Code:
$(function() {
var div = document.createElement('DIV'), button = document.createElement('INPUT'), cookie = my_getcookie('divState');
div.innerHTML = 'Hello';
div.id = 'containingElement'
if (cookie == 'hidden') div.style.display = 'none';
button.type = 'button';
button.value = 'Toggle';
button.onclick = function() {
var div = document.getElementById('containingElement');
if (/none/.test(div.style.display)) {
div.style.display = '';
my_setcookie('divState', 'shown');
} else {
div.style.display = 'none';
my_setcookie('divState', 'hidden');
}
};
document.body.appendChild(div);
document.body.appendChild(button);
});
The script creates two elements and appends them to the body; a button and container. The button toggles the display state of the container, and the cookies handle the state whenever the page is changed.
Re: javascript with cookeis
I'm stupid hhhhhhhhhhh , I'm not fully understand this manner ??
I have botton when I click it lead to make the display value of some elements is 'none'
I neesd to save it and
also for checkbox when is cheched or not
can you make example in html page
THANK YOU
I have botton when I click it lead to make the display value of some elements is 'none'
I neesd to save it and
also for checkbox when is cheched or not
can you make example in html page
THANK YOU
Similar topics
» Javascript- More then 1 javascript code
» Help With A JavaScript
» Javascript Help
» javascript
» javascript help plz
» Help With A JavaScript
» Javascript Help
» javascript
» javascript help plz
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum