Var y = <% = y %>; // The background retrieves the current year.
Var m = <% = m %>; // The background retrieves the current month.
// ------------ Load -------- In the onload () event --------
Function AddYearMonth ()
...{
Var objY = document. getElementById ("clsBudgetYear"); // clsBudgetYear: select the drop-down list id of the year.
Var objM = document. getElementById ("clsBudgetMonth"); // clsBudgetMonth: the drop-down list id of the month.
ObjY. length = 0; // delete all
// Only the current year and the following year can be selected
For (I = 0; I <2; I ++)
...{
ObjY. add (new Option (y + I, y + I); // fill the year
}
For (var I = 0; I <= 12-m; I ++)
...{
If (m + I <10)
...{
ObjM. add (new Option ("0" + (m + I), "0" + (m + I); // when the current month is a single digit: add 0
}
Else
...{
ObjM. add (new Option (m + I, m + I ));
}
}
}
// ----------- Fill in the month --------------------- when the selected year changes ---------------------
Function ChageAddYearMonth ()
...{
Var objY = document. getElementById ("clsBudgetYear"); // clsBudgetYear: select the drop-down list id of the year.
Var objM = document. getElementById ("clsBudgetMonth"); // clsBudgetMonth: the drop-down list id of the month.
ObjM. length = 0; // delete all
// When the year is selected as this year
If (objY. options [objY. selectedIndex]. value = y)
...{
For (var I = 0; I <= 12-m; I ++)
...{
If (m + I <10)
...{
ObjM. add (new Option ("0" + (m + I), "0" + (m + I); // when the current month is a single digit: add 0
}
Else
...{
ObjM. add (new Option (m + I, m + I); // fill the month
}
}
}
Else
...{
For (var I = 1; I <= 12; I ++)
...{
If (I <10)
...{
ObjM. add (new Option ("0" + I, "0" + I); // when the current month is one digit: add 0
}
Else
...{
ObjM. add (new Option (I, I); // fill the month
}
}
}
}