我创建的表单包括出生日期,当前日期,年龄文本框,默认情况下在文本框中显示当前日期,当选择出生日期我想要计算年龄和时间。将其显示在年龄文本框中.. 我的Java脚本代码:
<html>
<head>
<script language="javascript">
function aaa()
{
date= new Date();
var d = date.getDate();
var m= date.getMonth()+1;
var y= date.getFullYear();
document.getElementById('ddd').value=m + '/' + d + '/' + y;
}
function display()
{
var a = document.getElementById('eee').getDate.value;
var b = document.getElementById('eee').getMonth.value;
var c = document.getElementById('eee').getFullYear.value;
//var aa= document.getElementById('eee').(this).('getDate').value;
var e= y - c;
{
document.write("Ans="+e);
}
alret(e);
}
</script>
</head>
<body onload="aaa();">
<form name="xyz" method="post">
CurrentDate:<input type="text" name="ddd" id="ddd" readonly="readonly">
BirthDate:<input type="date" name="eee" id="eee">
Age:<input type="text" name="age" id="age">
<input type="submit" name="submit" value="submit" onClick="display();">
</form>
</body>
</html>