inko9nito
06-25-2007, 09:25 PM
I have this script that I got from some site. When you click on a link tied to a div it hides all other divs and displays just that one. Well, that works, but I want it to display one of the divs on page load based on today's date.
For example, it will display the "summer" div if today's date is anywhere between June 1 and August 31. When links to other divs are clicked that div will disappear and other ones will appear in its place. Anyway, here's the code, and I don't know anything about javascript so I have no idea where to even start editing it. Please help :(
<script type="text/javascript">
<!-- Layer Show/Hide Script
last=""
function changeDiv(the_div,the_change)
{
var the_style = getStyleObject(the_div);
if (the_style != false)
{
the_style.display = "block"
if(last!="")
{
last.display = "none"
}
}
last=the_style
}
function getStyleObject(objectId)
{
if (document.getElementById && document.getElementById(objectId))
{
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId))
{
return document.all(objectId).style;
}
else
{
return false;
}
}
//-->
</script>
For example, it will display the "summer" div if today's date is anywhere between June 1 and August 31. When links to other divs are clicked that div will disappear and other ones will appear in its place. Anyway, here's the code, and I don't know anything about javascript so I have no idea where to even start editing it. Please help :(
<script type="text/javascript">
<!-- Layer Show/Hide Script
last=""
function changeDiv(the_div,the_change)
{
var the_style = getStyleObject(the_div);
if (the_style != false)
{
the_style.display = "block"
if(last!="")
{
last.display = "none"
}
}
last=the_style
}
function getStyleObject(objectId)
{
if (document.getElementById && document.getElementById(objectId))
{
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId))
{
return document.all(objectId).style;
}
else
{
return false;
}
}
//-->
</script>