如何使用JavaScript日历在两个文本字段中获取日期值 [英] How to get the date value in two text fields using javascript calendar

查看:55
本文介绍了如何使用JavaScript日历在两个文本字段中获取日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从日期算起年龄.当我单击日历图像时,我将同时在DOB字段中获取日期,我也想计算年龄.如何使用Javascript执行此操作.

[从答案中移出]
我的问题是,我不知道如何在Showcalendar javascript函数[任何日历函数]中传递年龄控制ID.所有日历功能都只是创建日历并提供选定的日期.

I want to calculate the age from the date. when i click the calendar image i will get the date in DOB field at the same time i want to calculate the age also. How to do this from the Javascript.

[moved from answer]
My Question is , i don''t know how to pass the age control id in the Showcalendar javascript function [ any calendar function ]. all calendar functions are just creating the calendar and giving the selected date.

推荐答案

我想您需要这样的东西-http://www.hscripts.com/scripts/JavaScript/age-calculator.php [
I guess you need something like this - http://www.hscripts.com/scripts/JavaScript/age-calculator.php[^].


好吧,我不知道"看不到为什么只要尝试就能做不到.

您从日历中获得了一个日期.根据选择,您只需要找到所选日期和今天的日期之间的差额即可.现在,只需将差异显示为年,月和日即可.
Well, I don''t see why you would not be able to do it, if you just try it.

You got a date from a Calendar. Based on selection, you just need to find the difference of date selected and today''s date. Now, just display the difference as years, months and days.


您可以调用该函数来计算文本框的"onchange"事件的年龄,在该事件中,您将从中获取选择的日期日历.




函数calculateAge(txtBox)
{
///通过使用txtBox的值来计算年龄
}
You can call the function to calculate age on "onchange" event of the text box in which you are getting the date selected from the calendar.




function calculateAge(txtBox)
{
/// calculate age by using the value of txtBox
}


这篇关于如何使用JavaScript日历在两个文本字段中获取日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆