Hi guys,
I'm currently building a dynamic menu bar(vertical and horizontal). in the default position its vertical. the user have the option to show the horizontal position and hide and vertical. I am currently doing that with javascript/ jquery. in order to keep the menu bar in the horizontal position i am keeping a count with a cookie. the problem is that when i use the click function in javascript i want to change the value of the cookie. i have no knowledge of how to do this. Can anyone assist me with this. all help would be appreciated.
<?php
setcookie('menu', 1, time()+(86400));
?>
$(document).ready(function() {
$('#temp').hide();
if(<?php echo $_COOKIE['menu'];?> == 1){
$('#topmenu').hide();
$('#sidemenu').floating().dropShadow().floating();
$('#sidemenu_bottom').hide();
}else{
$('#topmenu').show();
$('#topmenu').dropShadow();
$('#sidemenu').hide();
$('#sidemenu').removeShadow();
}
$('#move').click(function(){
$('#sidemenu').hide("drop",{},2000);
$('#sidemenu').removeShadow();
$('#topmenu').show();
$('#topmenu').dropShadow();
$('#sidemenu_bottom').show();
$('#sidemenu_bottom').floating().dropShadow().floating();
});
});
This is what i have so far and the default cookie is working as well as the javascript. its just to change the cookie value now.
thanks.
This is what I have done since so far;
function set_cookie ( name, value, exp_y, exp_m, exp_d){
var cookie_string = name + "=" + escape ( value );
if ( exp_y ){
var expires = new Date ( exp_y, exp_m, exp_d );
cookie_string += "; expires=" + expires.toGMTString();
}
document.cookie = cookie_string;
}
var x = document.cookie;
if(x == "menu=1"){
$('#topmenu').show();
$('#topmenu').dropShadow();
}else{
$('#topmenu').hide();
$('#sidemenu').floating().dropShadow().floating();
$('#sidemenu_bottom').hide();
}
$('#move').click(function(){
set_cookie ( "menu", "1", 2012, 01, 15 );
$('#sidemenu').hide("drop",{},2000);
$('#sidemenu').removeShadow();
$('#topmenu').show();
$('#topmenu').dropShadow();
$('#sidemenu_bottom').show();
$('#sidemenu_bottom').floating().dropShadow().floating();
});
I'm however still having problems. Its not doing what i want it to do.
Regards.