html 測試 上入 下出

html 測試 單入 單出

html 測試 左右 各一 測試

html 測試 左入右出

尾部連結 hbbb(xx)

onload onscroll onresize

2018年3月5日 星期一

age calculator 計算年齡

age calculator 計算年齡

<input type="text" id="lower" value="YYYY/MM/DD" onmouseover="this.select()" onchange="agge()"> 
<div id="ageDP">
</div>
<script language="JavaScript">
function agge() {
var AgeDays  = 0;   
var AgeWeeks = 0;   
var AgeMonth = 0;   
var AgeYears = 0;   
var AgeRmdr  = 0;   
var DoC = new Date();   
var ddd = document.getElementById("lower").value;   
var DoB = new Date(ddd); 
if(isNaN(DoB .getTime())){
alert('err input YYYY/MM/DD');   
document.getElementById("lower").value= "YYYY/MM/DD";   
document.getElementById("lower").select();     }   
else {     mSecDiff   = DoC - DoB;   
AgeDays  = mSecDiff / 86400000;   
AgeWeeks = AgeDays / 7;   
AgeMonth = AgeDays / 30.4375;   
AgeYears = AgeDays / 365.24;       
AgeYears = Math.floor(AgeYears);   
AgeRmdr  = (AgeDays - AgeYears * 365.24) / 30.4375;         
AgeDays  = Math.round(AgeDays);   
AgeWeeks = Math.round(AgeWeeks);   
AgeMonth = Math.round(AgeMonth);   
AgeRmdr  = Math.round(AgeRmdr );       
var DP = "   AGE  : " + AgeYears + " and ";       
DP +=  AgeRmdr  + " months <br>" ;       
DP += "  days : " + AgeDays + "<br>" ;       
DP += " weeks : " + AgeWeeks + "<br>";       
DP += "months : " + AgeMonth + "<br>";     
document.getElementById("ageDP").innerHTML =DP;     
document.getElementById("lower").select(); } }
</script>

沒有留言:

張貼留言