www.webdeveloper.com
Results 1 to 3 of 3

Thread: pop up alert based on appointment time

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1

    Lightbulb pop up alert based on appointment time

    I have developed scheduler in which admin can make appointments of a patient on paticular date & time,and i want alert pop up before 10min of appointment..i tried but wnt get...How to get pop up alert by using javascript..do we have to use thread programming???

  2. #2
    Join Date
    Feb 2013
    Posts
    9
    Probably not optimal, but you can have a function that checks the time and sees if there are any appointments within 10 minutes. Popup a reminder if there is. Then you set this function to run periodically.

  3. #3
    Join Date
    Feb 2013
    Posts
    5
    You don't need thread programming to do that in javascript. You nead timing events:
    http://www.w3schools.com/js/js_timing.asp

    and to use objects of type date:
    http://www.w3schools.com/jsref/jsref_obj_date.asp

    you can implement something similar to this code that I've written:

    Code:
    <script type="text/javascript">
    var mins_alert=10;
    
    function alert_func(){
    	alert("in "+mins_alert+" minutes you will have an appointment!");
    	caller();
    }
    
    function caller(){
    	//get the current date
    	var now = new Date();
    
    	//get the next event (these values should come from a database or somewhere, and be update each time that the caller function is run...)
    	var month_str="february";
    	var day=28;
    	var year=2013;
    	var hours=22;
    	var mins=57;
    	var secs=0;
    	var next_event = new Date(month_str+day+", "+year+" "+hours+":"+mins+":"+secs);
    
    //	alert("now:\n"+now);
    //	alert("next_event:\n"+next_event);
    
    	var delta_millisecs = next_event.getTime()-now.getTime();	//difference, in milliseconds, between these the current date and the date of the next appointment
    	var delta_t = delta_millisecs-mins_alert*60*1000;		//number of milliseconds between now to the alert event
    	if (delta_t>0){
    		setTimeout("alert_func()", delta_t);
    	}
    }
    </script>
    Hope that helps!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles