LoginSignup
0
1

More than 5 years have passed since last update.

フォームに日付を追加

Posted at

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を設定
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1