Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Re: triggering link to var function


Message #1 by eelco.osseweijer@b... on Fri, 3 Aug 2001 13:24:39
>                                                                          
         var curDate = new Date(); 
>                                                                          
         var day = curDate.getDay(); 
> 
>                                                                          
         if (day == 0) 
>                                                                          
         //run Sunday function 
>                                                                          
         if (day == 1) 
>                                                                          
         //run Monday function 
>                                                                          
         if (day == 2) 
>                                                                          
         //run Tuesday function 
>                                                                          
         if (day == 3) 
>                                                                          
         //run Wednesday function 
>                                                                          
         if (day == 4) 
>                                                                          
         //run Thursday function 
>                                                                          
         if (day == 5) 
>                                                                          
         //run Friday function 
>                                                                          
         if (day == 6) 
>                                                                          
         //run Saturday function 
> here is the code: i want to create a link "Daily Specials" that will be 
placed in the body of a webpage, when this link is clicked I want the 
above 
> function to run, when it determines the day of  the week it is i want a 
specific html page to open with that days specials.
> so i need to know two things:
> #! how to call this function from a link
> #2 how to call a html page from the //run... action.
> 
> thanks
> james


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title>Your Title</title>
		<script>
		<!--
			function getDailySpecial() {
				var dCurDate = new Date();
				var iDay = dCurDate.getDay();
				var arrDays = new Array
("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
	   		var sUrl = arrDays[iDay] + '.htm'
				document.location.href = sUrl;
			}
		//-->
		</script>
	</head>
	<body>
		<a href="javascript:getDailySpecial();">Goto the daily 
special</a>
	</body>
</html>

Create 7  pages called Sun.html - Sat.html with the "daily special" 
content.

  Return to Index