A'kum......
saya sedang membangunkan satu sistem utk sistem rekod di salah sebuah hospital kerajaan,

guna PHP+Javascript+MySQL+Apache linux+HTML....

masalah dlm javascriptnya.......

macam mana autokan pengiraan haribulan supaya user tak masukkan nilai haribulan yg salah....

kod yg telah dibuat dinawah ini:

<script>
function validate_date() {
alert("yo");
theform = document.SearchRecordForm;
var total_day = 0;
selected_month_value = theform.month.value;
if(selected_month_value==01) {
total_day = 31;
theform.day.options.length = 0;
} else if(selected_month_value==02) {
total_day = check_february_total_day()
theform.day.options.length = 0;
} else if(selected_month_value==03) {
total_day = 31;
theform.day.options.length = 0;
} else if(selected_month_value==04) {
total_day = 30;
theform.day.options.length = 0;
} else if(selected_month_value==05) {
total_day = 31;
theform.day.options.length = 0;
} else if(selected_month_value==06) {
total_day = 30;
theform.day.options.length = 0;
} else if(selected_month_value==07) {
total_day = 31;
theform.day.options.length = 0;
} else if(selected_month_value==08) {
total_day = 31;
theform.day.options.length = 0;
} else if(selected_month_value==09) {
total_day = 30;
theform.day.options.length = 0;
} else if(selected_month_value==10) {
total_day = 31;
theform.day.options.length = 0;
} else if(selected_month_value==11) {
total_day = 30;
theform.day.options.length = 0;
} else if(selected_month_value==12) {
total_day = 31;
theform.day.options.length = 0;
}
for(i=1; i<=total_day; i++){
if(i<=9) {
i = "0"+i;
}
var day = new Option(i, i);
theform.day.options[theform.day.options.length] = day;
}
}
function check_february_total_day(){
theform = document.frmRegisterForm;
selected_year_value = theform.year.value;
// get current year
var this_year = "2003";
// This For loop is use to count total leap year from year 1920 to current year
var start_count_leap_year = 1920;
var count_total_leap = 0;
for(leap_year=start_count_leap_year; leap_year<=this_year; leap_year+=4){
count_total_leap = count_total_leap + 1;
}
// Generate the array to stored all leap year
var all_leap_year = new Array(count_total_leap);
// This For loop is use to generate all the leap year
var n = 0;
for(leap_year=start_count_leap_year; leap_year<=this_year; leap_year+=4){
all_leap_year[n] = leap_year;
n++;
}
// calculate the leap year and not leap year February total days
var i = 0;
while(i<count_total_leap){
if(selected_year_value==all_leap_year[i]){
total_day = 29;
i = count_total_leap + 1;
} else {
total_day = 28;;
i++;
}
}
return total_day;
}
</script>



#php:-

<td align="center"> <select name="doa_dates" onChange="validate_date()">
<option value="">--</option>
<option value="01"> 1 </option>
..........
</select> // ni baru utk satu date

dan seterusnya....

semua form haribulan ada 6:


[PHP]