此代碼是基於使用組合框的用戶的選定值來計算年齡,並且它必須在下面提供的文本框中顯示年齡。每次用戶更改組合框中的選定值時,都必須刷新年齡。但我目前的代碼並沒有顯示計算出來的年齡。年齡計算器不顯示計算的年齡
<?php
$month = date("m"); //without leading zero(o)
$year = date("Y"); //four digit format
$day = date("d");
$st_year = "1950"; //Starting Year
$month_names = array("January", "February", "March","April", "May", "June", "July", "August", "September", "October", "November", "December");
?>
<form name="Month_Year" id="Month_Year" method="post">
<select name="month" id="month">
<?php
for ($i=1; $i<=12; $i++) {
echo "<option ";
if ($i == $month) {
echo "selected=\"selected\" ";
}
echo "value=\"$i\">", $month_names[$i-1], "</option>\n";
}
?>
</select>
<select name="year" id="year">
<?php
for ($i=$st_year; $i<=$year; $i++) {
echo "<option ";
if ($i == $year) {
echo "selected=\"selected\" ";
}
echo "value=\"$i\">$i</option>\n";
}
?>
</select>
<select name="day" id="day">
<?php
for ($i=1; $i<=31; $i++) {
echo "<option> ";
if ($i == $day) {
echo "selected=\"selected\" ";
}
echo "value=\"$i\">$i</option>\n";
}
?>
</select>
// I used this code to combine the selected value in the combo box.
<?php $Convertdays = $month."/".$day."/".$year;
echo $Convertdays;
?>
<script type="text/javascript">
var birth = new Date(<?php '$Convertdays'?>);
var check = new Date();
var milliDay = 1000 * 60 * 60 * 24; // a day in milliseconds;
var ageInDays = (check - birth)/milliDay;
var ageInYears = Math.floor(ageInDays/365);
var age = ageInDays/365 ;
</script>
我每次改變組合框的值,該文本框會顯示0 讓我們假設該文本框的值是1991年10月19日它應該顯示21
請詳細描述您的問題。告訴我們究竟發生了什麼,有什麼錯誤信息,以及[你如何試圖解決這個問題。](http://whathaveyoutried.com/) – MathSquared 2013-04-21 00:34:56
onSelect/onChange監聽器在哪裏? – hop 2013-04-21 00:39:23
我編輯的代碼我把它放在每個