473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to fetch two different date value from textbox and display remaining day without

I have two date textbox(calender attached) after i enter date from calender i want to display in another textbox remaining day left using php or javascript
Sep 25 '13 #1
13 4598
Dormilich
8,658 Expert Mod 8TB
what have you tried?
Sep 25 '13 #2
I am using two textboxes fromdate and todate with calender if i enter two different date in that textbox, I wants to display remaining days left in another textbox from total leaves. Calender i was using javascript code...
Expand|Select|Wrap|Line Numbers
  1. FromDate:<input type="text" placeholder="YYYY-MM-DD" id="fdate" name="fdate" value="">&nbsp;<a href="javascript:show_calendar('document.leaveapp.fdate', document.leaveapp.fdate.value);"><img src="cals.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a></div>
  2.  
  3. ToDate:<input type="text" placeholder="YYYY-MM-DD" id="todate" name="todate" value="">&nbsp;<a href="javascript:show_calendar('document.leaveapp.todate', document.leaveapp.todate.value);"><img src="cals.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a></div>
Sep 26 '13 #3
Dormilich
8,658 Expert Mod 8TB
create 2 Date objects (via new Date(input.value)) and subtract these from each other and you get the time difference in milliseconds.

(tested in FF, Chrome)
Sep 26 '13 #4
Using javascript...how it will take values from textbox using calender date, without using submit button...
Sep 26 '13 #5
Dormilich
8,658 Expert Mod 8TB
you could hook into the input fields change event.
Sep 26 '13 #6
i am using below code but how it will take values from textbox, Before i was using submit button in body setion.


Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <script language="JavaScript" src="fromcalender.js"></script>
  4.         <script type="text/javascript">
  5.       function findDiff(){
  6.        //date= new Date(input.value);
  7.       var date1 = new Date(input.value);
  8.       var date2 = new Date(input.value);
  9.  
  10.       var day = 1000 * 60 * 60 * 24;
  11.       var d1 = date1.getTime();
  12.       var d2 = date2.getTime();
  13.       var diff = Math.abs(d1 - d2);
  14.       return (diff/day);
  15.  
  16.       }
  17.      </script>    
  18.  
  19.     </head>
  20.  <body>
  21. <form name="leaveapp">
  22.     FromDate:<input type="text" placeholder="YYYY-MM-DD" id="fdate" name="fdate" value="">&nbsp;<a href="javascript:show_calendar('document.leaveapp.fdate', document.leaveapp.fdate.value);"><img src="cals.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a></div>
  23.     ToDate:<input type="text" placeholder="YYYY-MM-DD" id="todate" name="todate" value="">&nbsp;<a href="javascript:show_calendar('document.leaveapp.todate', document.leaveapp.todate.value);"><img src="cals.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a></div>
  24. </form>
  25. </body>
  26. </html>
Sep 26 '13 #7
Dormilich
8,658 Expert Mod 8TB
how it will take values from textbox
you could hook into the input fields change event.

PS. lines #7/8, of course you need to provide the element, not just an arbitrary placeholder to get the input’s value.
Sep 26 '13 #8
i used change event <onchange="findDiff"> but its wouldn't show any result...
Sep 26 '13 #9
Dormilich
8,658 Expert Mod 8TB
have a look at the Error Console (hit F12).
Sep 26 '13 #10
i was using NetBeans...if i press F12 It wouldn't show any error...
Sep 26 '13 #11
Dormilich
8,658 Expert Mod 8TB
use a browser. F12 works there.
Sep 26 '13 #12
There is no error its logic error...
Sep 26 '13 #13
Dormilich
8,658 Expert Mod 8TB
I’d at least expect "undefined variable input" or "cannot get property value of undefined"
Sep 26 '13 #14

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

Similar topics

12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
4
by: Fang | last post by:
I try to use "\n" as line feed to put text into different lines in textBox of Visual Studio .Net, but it does not work. The text is still in one line. Does anybody know how to put text into...
0
by: Kevin | last post by:
Hi All Experts, Can any one tell me how to fetch the SSID value of AP in VC# programming language??? thanks & regards, Kevin
5
by: darrel | last post by:
I have the following right now to enter a date into SQL getting the data from some pull down menus: ------------------------------------------------- dim dateCCJApprovedDate as DateTime if...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
3
by: swinster | last post by:
Hi all, I have not touched access for a very long time and am attempting to help my nephew with his Video Rental Database. This is a simple three-table relationship database comprising a Video...
0
by: salo | last post by:
Hi ........Im working with c# and asp.net and i have two calendar control in my form and i want the cliked date value to be get displayed in the textbox. i gave the code as ...
1
by: hnpatel | last post by:
hi friends, How to get date in textbox from calender in vb.net? i want to get selected date in textbox onclick of calender. plz help me... thanx in advance...
1
by: naveenkongati | last post by:
Hi, How do we fetch only date and month from date column (Ex: 2008-11-10) in Mysql? Thanks
1
by: user1980 | last post by:
Hello there Can somebody help me with this. I have a form where the user enters his date of birth from 2 drop downs and a textbox. Month and date are dropdowns and year is to be entered in a text...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.