Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2004, 02:17 AM
Authorized User
 
Join Date: Dec 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting an alarm/alert

Hi everyone, hope someone can help me here.
I need to set an alert/alarm in my birthday asp page. Meaning I already keyed in my dates but i need a popup alert to state that whose birthday is due in 3 days time.

Does anyone know how I can code this?
 
Old December 30th, 2004, 09:09 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I assume you have birthdates in a table somewhere? Are these values some kind of date data type?(I would use a smallDateTime) If so, place the following either in an include file or the head of every page you want the alert to be triggered (include file better if you intend to use it in more than one location):
<%
  sql = "SELECT id FROM tblName WHERE birthDate = " & (date()+3) & ";"
  getInfo = conn.execute(sql)
  If NOT getInfo.EoF then
     'we have records. Break ASP, start JS and fire new window function
%>
     <script>
         var newWin
         newWin = window.open('birtdayAlert.asp','windowName',"width =300,height=300,top=100,left=100,scrollbars=1,resi zable=1,toolbar=0,location=0,status=0,menubar=0");
     </script>
<%
  ELSE
     'no bodys birthday is in three days time, do nothing
  END IF
%>

NOTE: Appart from the connection string, query and dimming variables that will be cut n paste code. Before you run it create a page called birtdayAlert.asp (as mentioned in the newWindow syntax) place the content you would like in the new window on this page. There are two ways to identify the persons who have a bDay in three days time on this page:
1..run the query again on birtdayAlert.asp (easier)
or
2..After the line getInfo = conn.execute(sql) loop thru records making a commer delimited string appending it as a query string to the destination page location EG 'birtdayAlert.asp?ids=<%= stringOfIds %>'

Have a fine NY

Wind is your friend
Matt
 
Old January 2nd, 2005, 09:02 PM
Authorized User
 
Join Date: Dec 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Matt,

Thanks for the reply. Will give it a shot and try it out. But I do have a problem here. If I have a list of items that I keyed in the dates and a time schedule for each alert.

U able to advise me on this?

Thanks Matt.
 
Old January 2nd, 2005, 09:18 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

hayley

;;;If I have a list of items that I keyed in the dates and a time schedule for each alert.

I am not clear on that one. When you say keyed in:
1..Are they going into a database
2..Is the data type some kind of dateTime
In addition what is the time schedule?
From your initial post I thought you were just keying in a single birthdate value

Wind is your friend
Matt
 
Old January 2nd, 2005, 09:33 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Hayley

Based on your first post the code I posted does work, I just tested it (hard coding dates).
It's 12.30pm in Australia the sea breeze has kicked in and the ocean is calling me!

Gone kitesurfing - Have a nice day

Wind is your friend
Matt
 
Old January 3rd, 2005, 08:31 AM
Authorized User
 
Join Date: Dec 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there Matt, thanks for replying.

I meant that besides the alert date that I have, I have for each registered person's name that will choose a schedule time. Meaning Perhaps for A, A wants to be alert abt this friend's birthday before 8000hrs. B may want to be alerted before 600 hrs. All in hours. So each scheduled alert dates to be alert is different. If words are keyed in instead of hours, it is skipped and ignored.

And yes the dates to be alerted and and brithdates are to be keyed into the database.
Hope u can understand...

 
Old January 3rd, 2005, 06:09 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

hayley - a couple of questions:

1..Is the birthdate value some kind of dateTime data type?
2..When you say
;;;If words are keyed in instead of hours, it is skipped and ignored.
What data type is this value being stored as?
Is the value validated in any way?
3..Each person enters how many hours they are to be alerted before 'all birthdays' or
do they have the ability to choose a specific time for each individual.


Wind is your friend
Matt
 
Old January 4th, 2005, 05:23 AM
Authorized User
 
Join Date: Dec 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Matt,

1.Yup it is a date/time data in access.

2. It is a text type. I actually wanna make it such that pple can edit and type such as "not sure", but at the same time I want the hours to be calulated if keyed correctly. Value needs not be validated.

3.Unable to choose the time. They have to key in teh hours themselves.

Thanks heaps.:)

 
Old January 4th, 2005, 05:57 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

hayley

Just so you are aware : The answer to 2.. could lead you to problems. Someone may type in
'12' or 'twelve' or '12 hours' if not validated you run the risk of:
a..Users thinking they will be getting alerts, 'twelve' will not get an alert.
b..Complicating calculations in your sql trying to convert a text field to hours.

Perhaps you could try:

<select>
 <option value="0">Not Sure</option>
 <option value="24">24 Hours</option>
 <option value="48">48 Hours</option>
 <...
</select>

Then you could have this field as an integer and users will be clear on when they will be alerted.

BTW: Have another read of 3.. I'm not sure how to write it clearer, an answer to this is key in
deciding how I would reach your objective.

Anyhow if using hours (I would use days myself) I would:
hourValue = users chosen hour figure (where ever this comes from (Q3..?))
daysInHourFigure = hourValue / 24 (get how many days)
newDateValue = date() + daysInHourFigure
'now use the dateDiff function, is result = our initial hourValue
hourDifference = DateDiff("h",birthDate,newDateValue)
if hourDifference = hourValue then
   ==
else
   <>
end if


Wind is your friend
Matt
 
Old January 12th, 2005, 09:50 PM
Authorized User
 
Join Date: Dec 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks so much mat41, will try it out as soon as possible. Been sick for sometime so sorry for the late reply.

Really appreciate ur replies. :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy whole sentence that contains "Alarm" mona_upm84 Excel VBA 3 September 10th, 2008 01:03 PM
Alarm Program nilgol1 Apache Tomcat 1 April 23rd, 2007 11:29 PM
alert darkhalf Javascript 3 November 18th, 2005 12:56 PM
Alarm Clock/How to Compare Set TIme mjwelker VB How-To 2 May 5th, 2004 05:04 AM
alert collie Javascript 2 December 29th, 2003 02:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.