473,473 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems adding an extra day depending on time in an order form

89 New Member
Hi' All

I have an ordering formular where users can choose on how many working days they want thier order on. I skip saturday and sunday because they are not working days and this works fine. If they place thier order after 3 o'clock in the afternoon an extra working day should be added. This also works fine in my script, but then the problem occurs. Instead of skipping staurday and sunday when they place their order after 3 o'clock, it skips sunday and monday. I use the below script to calculate and show the shipping date. Can anyone tell me what is wrong....

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function setDelivery(val) {
  3. var delivery = new Date(); // We start at the current date
  4. var theyear = delivery.getFullYear();
  5. var themonth = delivery.getMonth()+1;
  6. var theday = delivery.getDate();
  7. var thehours = delivery.getHours();
  8. var i = 0; 
  9. // i - The number of working days we have reached
  10. while (i < parseInt(val)) 
  11. // We continue until we have reached the desired working days
  12. {
  13. delivery.setDate(delivery.getDate() + 1); 
  14. // Always jump one day ahead
  15. if (delivery.getDay() != 0 && delivery.getDay() != 6) i++; 
  16. // If it is not a saturday or sunday we add a working day to i
  17. }
  18. if (delivery.getHours() >= 15){ 
  19. delivery.setDate(delivery.getDate() + 1); 
  20. }
  21. // Now delivery should contain the desired date.
  22. //you have the correct date...
  23. document.getElementById("shopform").shipdate.value = delivery.getDate() + "-" + (delivery.getMonth() + 1) + "-" + delivery.getFullYear();
  24. }
  25. // end Helpers -->
  26. </script>
Jan 22 '09 #1
1 1063
Dormilich
8,658 Recognized Expert Moderator Expert
there's maybe some problem after delivery.setDate(), every Date call after that is referencing the new date (btw. why do you have the current date values set when you don't use them?)
Jan 22 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tryfon Gavriel | last post by:
Hi all I recently noticed when trying to optimise a major query of a chess website I am the webmaster of, that adding an order by for "gamenumber" which is a clustered index field as in for...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
16
by: JCauble | last post by:
We have a large Asp.net application that is currently crashing our production servers. What we are seeing is the aspnet_wp eat up a bunch of memory and then stop unexpectedly. Does not recycle. ...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
1
by: CapRand | last post by:
Hi, I am creating an ASP.NET site and have created a form which I have been able to dynamically with listboxes, labels etc from a database - using mainly form1.Controls.Add ..... Does anyone...
6
by: Ken Foskey | last post by:
I am brand new to coding C# and Visual Studio. I have worked out how to configure the ComboBox creating my own object however it leave me with a lot of management updating as the table changes....
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.