1 に答える
0
コードをよりエレガントに書き直すことができます。
var dateformat = document.getElementById("dateformat"),
options = [{
text: month + "/" + day + "/" + fullyear,
value: "M/d/yyyy"
}, {
text: monthwz + "/" + daywz + "/" + fullyear,
value: "MM/dd/yyyy"
}, {
text: day + "/" + month + "/" + fullyear,
value: "d/M/yyyy"
}];
for (var i = 0, len = options.length; i < len; i++) {
var option = options[i],
element = new Option(option.text, option.value);
dateformat.options[dateformat.options.length] = element;
}
// one way to set the selected value:
dateformat.value = <?php print json_encode($value); ?>;
于 2013-03-27T16:44:53.577 に答える