Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to redirect to different pages, based on day and time. 1

Status
Not open for further replies.

garymgordon

Programmer
Apr 5, 2000
307
US
I have a script that uses Javascript that is shown below, that was written by another Tek-Tips Programmer named jemminger. (Thanks for his help on that. He was great!!)

But, I also now need to know how to basically get the exact same effect ... but using ASP (instead of Javascript) .. so the script can verify the dates and times (as you'll see below) - by looking at the server instead of the client's machine.

So, I need someone's help in re-writing this using ASP so it will accomplish the exact same task of sending a user to one page if it is BEFORE a particular date and time, then to another page if it is DURING a particular set of dates and times, and then to another page if it is AFTER the expiration date.

If someone can help me, I would greatly appreciate it.

Thanks,
Gary

HERE'S THE CURRENT JAVASCRIPT that needs to be converted to an ASP script:
==============================

<html>
<head>

<script language=&quot;javascript&quot;>
<!--

var expireYear = &quot;2002&quot;;
var expireMonth = &quot;12&quot;;
var expireDay = &quot;29&quot;;
var liveYear = &quot;2002&quot;;
var liveMonth = &quot;12&quot;;
var liveDay = &quot;27&quot;;

var dateLive = new Date(liveMonth+'-'+liveDay+'-'+liveYear);
var dateExpire = new Date(expireMonth+'-'+expireDay+'-'+expireYear);

function checkDate() {
var now = new Date();
var hh = now.getHours();
var dd = now.getDate();

var bLive = false, bExpire = false;

if (dd >= liveDay) {
if (dd > liveDay || hh >= 9) {
bLive = true;
}
}
if (!bLive) {
location.href = &quot;page1.html&quot;;
}
if (dd >= expireDay) {
if (dd > expireDay || hh >= 9) {
bExpire = true;
location.href = &quot;page3.html&quot;;
}
}
if (bLive && !bExpire) {
location.href = &quot;page2.html&quot;;
}
}

//-->
</script>

</head>
<body onload=&quot;checkDate();&quot;>
</body>
</html>

====================

Please help me if you can.

Thanks,
Gary

Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
server-side asp code

<%
dateLive = cDate('12/27/02 9:00 AM')
dateExp = cDate('12/29/02 9:00 AM')

rightNow = now()

if rightNow < dateLive then response.redirect &quot;page1.html&quot;
if rightNow > dateExp then response.redirect &quot;page3.html&quot;
response.redirect &quot;page2.html&quot;
%> Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
Mike,

Thank you very, very much.

For some reason I had to change the single quotes to double quotes in:

dateLive = cDate('12/27/02 9:00 AM')
dateExp = cDate('12/29/02 9:00 AM')

But, aside from that .. it is perfect.

THANK YOU!!!!

Gary

Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top