我不知道我做了什么,我不久前工作了,但我似乎无法找到我忘记的东西。我现在已经试图找到它一段时间,感谢任何帮助。
当它停止工作时,我正在处理ageDate和ageTime部分,如果这有帮助的话
<head>
<title></title>
</head>
<body>
Welcome to the Age Calculator!
<br>
<br>
<br>
<form name="form">
Birth Year:
<br>
<input type="text" id="birthYear">
<br>Current Year:
<br>
<input type="text" id="currentYear">
<br>
<br>
<br>Birth Month:
<br>
<input type="text" id="birthMonth">
<br>Current Month
<br>
<input type="text" id="currentMonth">
<br>
<br>
<br>Birth Date
<br>
<input type="text" id="birthDate">
<br>Current Date
<br>
<input type="text" id="currentDate">
<br>
<br>
<br>Birth Time (Convert time to a decimial Ex: 9:45pm = 21.75
<br>
<input type="text" id="birthTime">
<br>Current Time
<br>
<input type="text" id="currentTime">
<br>
<br>
<a id="Submit_Button" onclick="test();" href="javascript:void(0);" title="Submit">Submit</a>
</form>
<script type="text/javascript">
function test() {
var currentYear = document.getElementById("currentYear");
var birthYear = document.getElementById("birthYear");
var ageYear = (currentYear.value - birthYear.value)
var birthMonth = document.getElementById("birthMonth");
var currentMonth = document.getElementById("currentMonth");
if (birthMonth.value < currentMonth.value) {
var ageMonth = (currentMonth.value - birthMonth.value)
} else {
var ageMonth = (12 - (birthMonth.value - currentMonth.value))
}
var birthDate = document.getElementById("birthDate");
var currentDate = document.getElementById("currentDate");
if (birthDate.value < currentDate.value) {
var ageDate = (currentDate.value - birthDate.value);
} else {
var ageDat = (30 - birthDate.value);
var ageDate = (curentDate.value + ageDat);
}
var birthTime = document.getElementById("birthTime");
var currentTime = document.getElementById("currentTime");
if (birthTime.value > currentTime.value) {
var ageTim = ((birthTime.value + currentTime.value) % 1);
var ageTime = ((24 - (birthTime.value - ageTim) + currentTime.value);
} else {
var ageTim = ((currentTime.value - birthTime.value) % 1);
var ageTime = ((currentTime.value - birthTime.value) - ageTim);
}
alert("You are " + ageYear + " years, " + ageMonth + " months, " + ageDate + " days, " + ageTime + " hours, and " + ageMin + " minutes old.");
}
</script>
</body>
答案 0 :(得分:3)
您遇到语法错误。这样:
var ageTime = ((24 - (birthTime.value - ageTim) + currentTime.value);
应该是:
var ageTime = (24 - (birthTime.value - ageTim) + currentTime.value);