Not sure if I would classify myself as a newbie, but I am new to PHP. I've been coding with classic ASP and ASP.net for a while now and thought I'd try my hand at PHP.
On one of my ASP pages I have this JavaScript that I use and I wanted to use it on my PHP page, but for some reason it isn't working right. The images does change, but it isn't storing the cookie. I'm at a loss at what to do. Here's what I have on my PHP page:
print "
<script language='JavaScript'>
function toggleWindow(sWindow)
{
var when = new Date();
when.setTime(when.getTime() + 24 * 60 * 60 * 1000);
when.setFullYear(when.getFullYear() + 1);
if (document.all) {
if (document.all(sWindow).style.display == 'none') {
document.all(sWindow).style.display = 'block';
sWin = sWindow + \"_option\";
document.images(sWin).src = 'images/minimize.gif';
document.images(sWin).alt = 'Collapse This Window';
document.cookie = sWindow + \"=TRUE;expires=\" + when.toGMTString();
}
else {
document.all(sWindow).style.display = 'none';
sWin = sWindow + \"_option\";
document.images(sWin).src = 'images/maximize.gif';
document.images(sWin).alt = 'Open This Window';
document.cookie = sWindow + \"=FALSE;expires=\" + when.toGMTString();
}
}
else if (document.getElementById) {
if (document.getElementById(sWindow).style.display == 'none') {
document.getElementById(sWindow).style.display = 'block';
document.getElementById(sWindow).style.visibility = 'visible';
sWin = sWindow + \"_option\";
document.images[sWin].src = 'images/minimize.gif';
document.images[sWin].alt = 'Collapse This Window';
document.cookie = sWindow + \"=TRUE;expires=\" + when.toGMTString();
}
else {
document.getElementById(sWindow).style.display = 'none';
document.getElementById(sWindow).style.visibility = 'hidden';
sWin = sWindow + \"_option\";
document.images[sWin].src = 'images/maximize.gif';
document.images[sWin].alt = 'Open This Window';
ddocument.cookie = sWindow + \"=FALSE;expires=\" + when.toGMTString();
}
}
}";
Here's where I'm calling this function:
print "<img align='right' name='MainMenu_option' id='MainMenu_option' src='images/maximize.gif' border='0' alt='Expand This Window' width='15' height='15' onClick=\"javascript: toggleWindow('MainMenu');\" onmouseover=\"this.style.cursor='hand'\">";
I've tried every different variety, including completely removing the expiration date on the cookie. Nothing works. The page is set up to refresh from the server, not sure if that has anything to do with it.
Does anyone here see where I went wrong?