Dominick
04-30-2003, 12:08 PM
Hi everyone and thanks for taking the time to check this out.
I have a nifty little script that shows/hides content on a single page when an image is clicked, which I have included below.
I am trying to set a cookie that will remember the user's last view (shown/hidden) when they return to the page.
I have never dropped a cookie so I am starting from scratch. I will do some research on this, but of course I need to get this going ASAP so I thought I'd ask the experts in hopes of saving time and learning something.
Thanks so much for your help.
Regards,
Dominick
========================================
<html>
<head>
<title></title>
<style>
td {
font-family : verdana;
font-size : 11px;
}
</style>
<script language="JavaScript">
function toggleElement(szId) {
var el = document.getElementById ? document.getElementById(szId) : document.all ? document.all[szId] : null;
if (! el) return;
el.style.display = el.style.display == "none" ? "block" : "none";
var theimage=document.getElementById('Image1').src;
if (theimage=="http://www.geocities.com/dominickpagano/close.gif") {document.getElementById('Image1').src="http://www.geocities.com/dominickpagano/open.gif"}
if (theimage=="http://www.geocities.com/dominickpagano/open.gif") {document.getElementById('Image1').src="http://www.geocities.com/dominickpagano/close.gif"}
}
function showStuff(){
var showStuff = ""
showStuff += "<table bgcolor=838383 border=0 cellpadding=5 cellspacing=0 width=150>"
showStuff += "<tr>"
showStuff += "<td><input type=image src=http://www.geocities.com/dominickpagano/close.gif onClick=toggleElement('data') name=Image1 id=Image1></td>"
showStuff += "</tr>"
showStuff += "</table>"
showStuff += "<table border=0 bgcolor=e0e0e0 cellpadding=10 cellspacing=0 id=data style=display:show; width=150>"
showStuff += "<tr>"
showStuff += "<td align=center>Expanded view</td>"
showStuff += "</tr>"
showStuff += "</table>"
if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) <= 4){
document.write("Sorry, IE or NN 6 only.");
}
else {
document.write(showStuff);
}
document.close()
}
</script>
</head>
<body>
<div align="center">
<script language="javascript">
<!--
showStuff()
// -->
</script>
<table border=0 bgcolor=838383 cellpadding=0 cellspacing=0 width=150>
<tr>
<td> </td>
</tr>
</table>
</div>
</body>
</html>
I have a nifty little script that shows/hides content on a single page when an image is clicked, which I have included below.
I am trying to set a cookie that will remember the user's last view (shown/hidden) when they return to the page.
I have never dropped a cookie so I am starting from scratch. I will do some research on this, but of course I need to get this going ASAP so I thought I'd ask the experts in hopes of saving time and learning something.
Thanks so much for your help.
Regards,
Dominick
========================================
<html>
<head>
<title></title>
<style>
td {
font-family : verdana;
font-size : 11px;
}
</style>
<script language="JavaScript">
function toggleElement(szId) {
var el = document.getElementById ? document.getElementById(szId) : document.all ? document.all[szId] : null;
if (! el) return;
el.style.display = el.style.display == "none" ? "block" : "none";
var theimage=document.getElementById('Image1').src;
if (theimage=="http://www.geocities.com/dominickpagano/close.gif") {document.getElementById('Image1').src="http://www.geocities.com/dominickpagano/open.gif"}
if (theimage=="http://www.geocities.com/dominickpagano/open.gif") {document.getElementById('Image1').src="http://www.geocities.com/dominickpagano/close.gif"}
}
function showStuff(){
var showStuff = ""
showStuff += "<table bgcolor=838383 border=0 cellpadding=5 cellspacing=0 width=150>"
showStuff += "<tr>"
showStuff += "<td><input type=image src=http://www.geocities.com/dominickpagano/close.gif onClick=toggleElement('data') name=Image1 id=Image1></td>"
showStuff += "</tr>"
showStuff += "</table>"
showStuff += "<table border=0 bgcolor=e0e0e0 cellpadding=10 cellspacing=0 id=data style=display:show; width=150>"
showStuff += "<tr>"
showStuff += "<td align=center>Expanded view</td>"
showStuff += "</tr>"
showStuff += "</table>"
if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) <= 4){
document.write("Sorry, IE or NN 6 only.");
}
else {
document.write(showStuff);
}
document.close()
}
</script>
</head>
<body>
<div align="center">
<script language="javascript">
<!--
showStuff()
// -->
</script>
<table border=0 bgcolor=838383 cellpadding=0 cellspacing=0 width=150>
<tr>
<td> </td>
</tr>
</table>
</div>
</body>
</html>