Synergy!360でフォームに日付プルダウンを設定する時に作成。
//selectに変更
$('#aaa').replaceWith(function() {
var tag_class = $(this).attr("name");
var tag_id = $(this).attr("id");
if ( tag_class == null) {
var tag_class_plus =[];
} else {
var tag_class_plus = 'name="'+tag_class+'"';
}
if ( tag_id == null ) {
var tag_id_plus =[];
} else {
var tag_id_plus = 'id="'+tag_id+'"';
}
$(this).replaceWith('<select '+tag_id_plus+' '+tag_class_plus+'>'+$(this).html()+'</select>');
});
//日付を設定
var select = document.getElementById('aaa');
function generateDateString(offset) {
var weekdays = new Array('日', '月', '火', '水', '木', '金', '土');
var date = new Date();
date.setDate(date.getDate() + offset);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var wdindex = date.getDay();
var wday = weekdays[wdindex];
var datestr = year + '年' + month + '月' + day + '日 (' + wday + ')';
return datestr;
}
// aaaのところは任意のIDを設定