mcmuney Posted June 30, 2007 Share Posted June 30, 2007 I need a javascript if/else statement that will be placed on an IMAGE LINK. On click, it will check to see if the users date/time falls in a weekend (Sat and Sun). -If it does, it will continue to the hyperlink and load the page. -If it does NOT fall in a weekend, it will check to see if it's between the hours of 9-10. -If it is then it will continue to the hyperlink and load the page. -If it is NOT, then it will load a different page. I've searched and searched the net, but couldn't find anything close. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/57810-java-ifelse-statement-with-time/ Share on other sites More sharing options...
RichardRotterdam Posted June 30, 2007 Share Posted June 30, 2007 wouldn't it be better to do this serverside instead of clientside? javascript can always be disabled. with php you can easily get the day name out of the the date with the function date() Quote Link to comment https://forums.phpfreaks.com/topic/57810-java-ifelse-statement-with-time/#findComment-286526 Share on other sites More sharing options...
mcmuney Posted July 1, 2007 Author Share Posted July 1, 2007 Well, right now i'm using PHP, but the problem with that is that it uses server time and NOT user time. Quote Link to comment https://forums.phpfreaks.com/topic/57810-java-ifelse-statement-with-time/#findComment-286994 Share on other sites More sharing options...
mainewoods Posted July 2, 2007 Share Posted July 2, 2007 code your link like this: <a href="the url" onclick="return checktime();"><img src="url"></a> the checktime() routine will be coded to return either true or false depending on the time tests: <script> function checktime() { // time test checks if (timeOk) { return true; // causes the original href to be followed } return false; // the original href will not be followed } </script> Quote Link to comment https://forums.phpfreaks.com/topic/57810-java-ifelse-statement-with-time/#findComment-287530 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.