FeldmanSkitzoid
10-12-2003, 02:33 PM
Hi, I've got a bit of a problem with a script I've been working on. It uses cookies to set a variable, but when I try to get the variable to execute a function, it doesn't do anything.
The page is located here (http://www.theinsaneasylum.com/layout_2003/center/quote.php). You probably want to see what it's doing. Just click the header text. Essentially, I want it to remember if a person had the box "rolled up" or not. I'm modifying someone else's code so it remembers.
Here's the javascript:
<script type="text/javascript">
//Toggle Boxes Script
var toggle_thingy = unescape(document.cookie); //I added this
function toggle( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
//Unroll
if (target.style.display == "none"){
target.style.display = "";
toggle_thingy = 0; //I added this
document.cookie = escape(toggle_thingy); //I added this
} else {
//Roll
target.style.display = "none";
toggle_thingy = target.style.display; //I added this
document.cookie = escape(toggle_thingy); //I added this
}
}
}
</script>
and directly beneath that:
<script type="text/javascript">
if (toggle_thingy == "none"){
toggle('center_quote');}
</script>
I get the feeling that the problem is in that second line, but I can't figure out what. I have to admit, I'm pretty bad with javascript.
Thanks for any help you can give!
The page is located here (http://www.theinsaneasylum.com/layout_2003/center/quote.php). You probably want to see what it's doing. Just click the header text. Essentially, I want it to remember if a person had the box "rolled up" or not. I'm modifying someone else's code so it remembers.
Here's the javascript:
<script type="text/javascript">
//Toggle Boxes Script
var toggle_thingy = unescape(document.cookie); //I added this
function toggle( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
//Unroll
if (target.style.display == "none"){
target.style.display = "";
toggle_thingy = 0; //I added this
document.cookie = escape(toggle_thingy); //I added this
} else {
//Roll
target.style.display = "none";
toggle_thingy = target.style.display; //I added this
document.cookie = escape(toggle_thingy); //I added this
}
}
}
</script>
and directly beneath that:
<script type="text/javascript">
if (toggle_thingy == "none"){
toggle('center_quote');}
</script>
I get the feeling that the problem is in that second line, but I can't figure out what. I have to admit, I'm pretty bad with javascript.
Thanks for any help you can give!