Forum Moderators: open

Message Too Old, No Replies

Auto Redirect

Auto redirecting a drop down to.....

         

kingrbean

4:31 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



Hello All,

I am new and this is my first posting to this site.

I was wondering if someone can assist me in setting up a dropdown menu for a calendar. Has 12 months and month is displayed in an iframe.

Can I set this up so that when the page loads, it can read my system and direct the current month to the iframe?

If there is already a posting on this, I can visit it.

Thank you in advance for your attention.

kingrbean

ajkimoto

6:16 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



kingrbean,

First of all: Welcome to Webmaster World!

You can indeed set the src of the iframe based on the current month.

The function setDate() below gets the current date according to the system clock of the browser's computer. It gets the current month from this and then uses the resulting curMonth variable to reset the src of the iframe. I was not sure how you were generating your calendar, but this example passes the month as a parameter--you could just as easily use the curMonth variable to build the name of the html page.

<script type="text/javascript">
<!--

function setDate(){
//create date variable
curDate=new Date()
//extract the current month from curDate using the built-in getMonth() function
//note that the month is returned in 'zero based' format where January=0
var curMonth=curDate.getMonth()+1
//Set the src of the iframe based on the month
document.getElementById('monthFrame').src='baby_jason0'+curMonth+'04.htm'
//document.getElementById('monthFrame').src='calendar.htm?curmonth='+curMonth

}

//-->
</script>

</head>

<body onload="setDate()">
<iframe id="monthFrame" src=""></iframe>
</body>

Hope this helps,

ajkimoto

kingrbean

7:19 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



Thank you very much ajkimoto

This is good enough for me to work with and I am sure to get the results I need.

Thank you again, especially for your timely response.

Appreciative,
kingrbean