473,658 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to code to calculate the date based on the user select date and the duration?

65 New Member
Dear all;

Can someone guide me how to code out the javascript to calculate the estimate date based on the user selected date and the how long the duration in term of week.

eg. 19/9/2007 is select by user
1 weeks is duration also select by user

ans: 26/9/2007

Thanks for ur help.
Sep 19 '07 #1
3 1876
dmjpro
2,476 Top Contributor
Dear all;

Can someone guide me how to code out the javascript to calculate the estimate date based on the user selected date and the how long the duration in term of week.

eg. 19/9/2007 is select by user
1 weeks is duration also select by user

ans: 26/9/2007

Thanks for ur help.
Good Idea! :)
But post some code here you have already.
Then we will help you to achieve your Goal and I promise you, you will really enjoy with us while solving a problem.

Kind regards,
Dmjpro.
Sep 19 '07 #2
wish
65 New Member
I'm not expert in javascript and never learn before when in college..Then how do i start the script?
Sep 19 '07 #3
dmjpro
2,476 Top Contributor
I'm not expert in javascript and never learn before when in college..Then how do i start the script?
Ok!.
Try this Code.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>Simple Date Test</title>
  4.         <script language = "JavaScript">
  5.             //Paste the JavaScript function here.
  6.         </script>
  7.     </head>
  8.     <body>
  9.         <input type = "text" id = "date">
  10.         <input type = "text" id = "duration">
  11.         <input type = "button" onclick = "getDate()" value = " Get Value ">
  12.         <input type= "text" readonly id = "op">
  13.     </body>
  14. </html>
  15.  
Expand|Select|Wrap|Line Numbers
  1. function getDate()
  2.             {
  3.             try{
  4.                 var _date = document.getElementById("date").value, _duration = document.getElementById("duration").value;
  5.                 var date_obj = new Date(); /*Assusmed that your date pattern is dd/mm/yyyy*/
  6.                 date_obj.setFullYear(_date.substring(_date.lastIndexOf('/')+1)
  7.                 ,_date.substring(_date.indexOf('/')+1,_date.lastIndexOf('/'))-1
  8.                 ,_date.substring(0,_date.indexOf('/')));
  9.                 date_obj.setDate(date_obj.getDate()+parseInt(_duration));
  10.                 //alert(date_obj.getDate());
  11.                 document.getElementById('op').value = date_obj.getDate()+'/'+(date_obj.getMonth()+1)+'/'+date_obj.getFullYear();
  12.                 }catch(e){alert(e.description);}
  13.             }
  14.  
Good Luck.

Kind regards,
Dmjpro.
Sep 19 '07 #4

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

Similar topics

3
17909
by: CrystalDBA | last post by:
I am using SQL Server 2000. I need to query my database for all the contracts that came in during a certain time frame (user is prompted for reportingperiodid). Table - Periods Fields - Reporting Period id int Reporting Period desc varchar(30) Reporting Period Begin Date datetime Reporting Period End Date datetime
7
2821
by: Sunny K | last post by:
Hi guys, whilst working on a project which I thought was nearly complete I have come across a problem which was some how over seen, which I am hoping one of you guys know how to resovle. Firstly here is the script to create the table and insert some sample data:
4
9500
by: Andy Gayton | last post by:
Hey all, It looks like dynamic changes to a html document are only redrawn when the current code snippet comes to an end. For example the following page changes the text in a span, waits for a bit, and then sets the text in the span to something else when done. You don't see the change though. -----
1
1920
by: carl bloc | last post by:
Have this much done but need help with this bit of code: allow user to modify existing draw data. I think I need a counter to give week numbers so the user can select a week number rather than a date. I need to view data for a selected week given the week number or date. need some controls on not allowing the ball number to go >49 or <0 and no duplicates.
3
2168
by: Iain Miller | last post by:
Can anybody help me with some Access 2000 code? I don't do a lot of coding in Access & so every time I come back to do something I pretty much have to relearn the syntax from scratch so this is taking me hours. As with most occasional programmers its the commas, colons, inverted commas, square brackets etc etc that cause the problem! (Not to mention the nuances of using Do While, Do until, Case statements If statements, IIF etc etc...)...
4
2750
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last time i ask for an entire code or u can give me the outine of what to do and i ll do it by myself. the description is the following: the program will read a text file that contains historical price of a stock. The program will allow users to query...
5
7844
by: infobescom | last post by:
Hi I am wrking on a application where i need to calculate the difference between two dates .. here is the formula i am using ........ Public Function GetNumberOfWorkDays(sStartDate, sEndDate) Dim iWorkDays
3
1943
by: Hazza | last post by:
Hi, I am using PHP and mysql to create a website. I am fairly new to PHP, and thus am grateful to anyone who helps! Firstly I am running a homepage, that displays additional content if a user has logged in. I set a loggedin session in the log in page, which I have tested and works fine in other scripts. I am displaying news on the homepage (which is stored in a mysql database), and this works fine when the user accesses the homepage...
5
3858
by: vamsioracle | last post by:
Hi all, I have a problem with the ult_smtp package. Let me explain how the structure of my code is procedure------------ begin declarations of variables and cursors ........................ .....................
0
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
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 we have to send another system

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.