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 6 of 6

Thread: Date script

  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date script

    Hi,

    can anyone help point me in the right direction for a date script which displays tmorrows date unless its saturday in which it displays monday

    basically i run a balloon website and we have a panel which tells our customers the next delivery date.


    thanks to anyone that can help an amature :-)

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Code:
    function nextDeliveryDate(){
    	var d = new Date();
    	var offset = d.getDay() != 6 ? 1000*3600*24 : 1000*3600*48;
    	d.setTime(d.getTime() + offset);
    	return d;
    }
    alert(nextDeliveryDate().toDateString());

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks ever so much,

    but just to be a pain... how do insert this into a html page?

    Thankyou!

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok got it.. just need to change the alert to text :-)

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script type="text/javascript">

    function nextDeliveryDate(){
    var d = new Date();
    var offset = d.getDay() != 6 ? 1000*3600*24 : 1000*3600*48;
    d.setTime(d.getTime() + offset);
    return d;
    }
    alert(nextDeliveryDate().toDateString());

    </script>

    <input type="text" onLoad="" value="">
    Can anyone help put this function into the textbox insead of an alert

    Thanks

  • #6
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Code:
    <script type="text/javascript">
    function nextDeliveryDate(){
    	var d = new Date();
    	var offset = d.getDay() != 6 ? 1000*3600*24 : 1000*3600*48;
    	d.setTime(d.getTime() + offset);
    	return d;
    }
    window.onload = function(){
    	document.getElementById('delivery_date').value = nextDeliveryDate().toDateString();
    };
    </script>
    <input id="delivery_date" type="text" />


  •  

    Posting Permissions

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