var now = new Date();
function setDate(type, id, from, to) {
var str = "";
for (var i = from; i < to + 1; i++) {
if ((type == "y" && i == now.getFullYear()) || (type == "m" && i == now.getMonth() + 1) || (type == "d" && i == now.getDate()))
str = str + "<option selected='selected'>" + i + "</option>";
else
str = str + "<option>" + i + "</option>";
}
document.getElementById(id).innerHTML = str;
}
setDate("d", "day2", 1, 31);
function $() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
就这么简单,不谢。