Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: pickup time

  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    pickup time

    for today, it shows the hours from now up until closing time. If the user changes the day to tomorrow or another future date , I want to show all hours of the day, from open til close


    here is the piece of code :
    i know i have to use some javascript. can somebody help please ?



    <label>Pickup Time</label>
    <select name="pickuptime">
    <?

    $i=date('G', time());
    $i++;
    while($i<18)
    {
    $date = gmmktime($i, 0, 0, gmdate("m") , gmdate("j",$selectDate), gmdate("Y"));
    if($date==$_SESSION['pickuptime'])
    {
    echo "<option selected value=\"".$i."\">".gmdate('H:00',$date)."</option>";
    }
    else
    {
    echo "<option value=\"".$i."\">".gmdate('H:00',$date)."</option>";
    }
    $i++;
    }

    ?>
    </select>

  • #2
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    216
    Thanks
    0
    Thanked 29 Times in 27 Posts
    This page (which use the jQuery datepicker) is to update with the pikupTimes (See this variable, an array of arrays) for all the days of the week (from Sunday to Saturday).
    Code:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>Pickup Dates and Times</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    </head>
    <body>
    	<p>Date: <input type="text" id="datepicker" /></p>
    	<p><select id="tme"></select></p>  
    <script>
    pickupTimes=[[],[10,11,12,13,14,15,16,17,18],[10,11,12,13,14,15,16,17,18],[10,11,12,13,14,15,16,17,18],[10,11,12,13,14,15,16,17,18],[10,11,12,13,14,15,16,17,18],[10,11,12]];
    $(function(){
     	$( "#datepicker" ).datepicker({
    		minDate:new Date(),
    		dateFormat:'D, d M y',
    	 	onSelect: function(dateText, inst) { 
          	 	 	var date = $(this).datepicker('getDate'),
             	 	 	day  = date.getDate(),  
                 	 	 	month = date.getMonth() + 1,              
                 	 	 	year =  date.getFullYear(),
                 	 	 	today=new Date();
    		 	var slc=document.getElementById('tme');
          	 	 	slc.options.length=0;
          	 	 	var times=pickupTimes[date.getDay()];
          	 	 	okCondition = day==today.getDate() && month-1==today.getMonth() && year==today.getFullYear();
    			// alert(okCondition+'\n'+day+' '+month+' '+year+'\n'+today.getDate()+' '+today.getMonth()+' '+today.getFullYear()) 
       		 	for (var i=0;i<times.length;i++){
    				if (!okCondition || today.getHours()<=times[i]) slc.options[slc.options.length]=new Option(times[i]+':00',times[i])}
           	 	if (!times.length) alert("Sunday is closed !");
           	 	}
    	});   
    });  
    </script>
    </body>
    </html>
    Last edited by 007julien; 07-01-2013 at 03:25 PM.


  •  

    Posting Permissions

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