MBCUK
05-19-2009, 12:30 PM
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 :-)
venegal
05-19-2009, 12:53 PM
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());
MBCUK
05-19-2009, 01:04 PM
Thanks ever so much,
but just to be a pain... how do insert this into a html page?
Thankyou!
MBCUK
05-19-2009, 01:07 PM
ok got it.. just need to change the alert to text :-)
MBCUK
05-19-2009, 01:15 PM
<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
venegal
05-19-2009, 01:33 PM
<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" />