if(getCookie("response") == null)
{
document.getElementById('hide').style.display = 'none';
alert("Yipee");
}
else
{
//on approve creating a new cookie
function a()
{
var a = document.getElementById('approve');
document.getElementById('hide').style.display = 'none';
var expDate = new Date();
expDate.setDate(expDate.getDate() + 7);
document.cookie = 'response=approve;expires=' + expDate.toUTCString();
alert(document.cookie);
}
//on reject creating a new cookie
function r()
{
var a = document.getElementById('reject');
document.getElementById('hide').style.display = 'none';
var expDate = new Date();
expDate.setDate(expDate.getDate() + 7);
document.cookie = 'response=reject;expires=' + expDate.toUTCString();
alert(document.cookie);
}
}
</script>
<body>
<div id="hide">
<form>
<p id="p">Heya!</p>
<input type="button" id='approve' value="approve" onclick="a()"/>
<input type="button" id='reject' value="reject" onclick="r()"/>
</form>
THis is my code...I want to hide an element if a cookie exists and if not, i want to go ahead and display the form. No matter what, the form is always displayed and the "yipee" alert box does not appear.
I check with Chrome and it has the cookie called response for localhost.
Thanks for all your help.