Forum Moderators: open

Message Too Old, No Replies

Onclick to change cookie value

         

SoulMaster

4:17 pm on Jan 30, 2008 (gmt 0)

10+ Year Member



I need something what would change cookies value onclick. I have button, and I have a script that hides 2 divs but it should also decrease cookies value by 1...help plz.

[edited by: encyclo at 2:08 am (utc) on Jan. 31, 2008]
[edit reason] corrected spelling [/edit]

SoulMaster

5:30 pm on Jan 31, 2008 (gmt 0)

10+ Year Member



ok i got my solution

stajer

5:39 pm on Jan 31, 2008 (gmt 0)

10+ Year Member



Can you post your solution - I am interested and I think others may be to. I am not sure how you can us js to change a header value.

SoulMaster

9:56 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



[codes]
<script type="text/javascript">
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null)? "" : ";expires="+exdate.toGMTString());
}
function checkCookie(){
if(getCookie('kors')==null ¦¦ getCookie('kors')==""){
setCookie('kors', 3);
}
}
function showandhide(esimene,teine){
document.getElementById(esimene).style.visibility="hidden";
document.getElementById(teine).style.visibility="hidden";
var korreke = getCookie('kors');
var korrekene = korreke-1;
setCookie('kors', korrekene);
}
</script>
[/codes]