모바일 오유 바로가기
http://m.todayhumor.co.kr
분류 게시판
베스트
  • 베스트오브베스트
  • 베스트
  • 오늘의베스트
  • 유머
  • 유머자료
  • 유머글
  • 이야기
  • 자유
  • 고민
  • 연애
  • 결혼생활
  • 좋은글
  • 자랑
  • 공포
  • 멘붕
  • 사이다
  • 군대
  • 밀리터리
  • 미스터리
  • 술한잔
  • 오늘있잖아요
  • 투표인증
  • 새해
  • 이슈
  • 시사
  • 시사아카이브
  • 사회면
  • 사건사고
  • 생활
  • 패션
  • 패션착샷
  • 아동패션착샷
  • 뷰티
  • 인테리어
  • DIY
  • 요리
  • 커피&차
  • 육아
  • 법률
  • 동물
  • 지식
  • 취업정보
  • 식물
  • 다이어트
  • 의료
  • 영어
  • 맛집
  • 추천사이트
  • 해외직구
  • 취미
  • 사진
  • 사진강좌
  • 카메라
  • 만화
  • 애니메이션
  • 포니
  • 자전거
  • 자동차
  • 여행
  • 바이크
  • 민물낚시
  • 바다낚시
  • 장난감
  • 그림판
  • 학술
  • 경제
  • 역사
  • 예술
  • 과학
  • 철학
  • 심리학
  • 방송연예
  • 연예
  • 음악
  • 음악찾기
  • 악기
  • 음향기기
  • 영화
  • 다큐멘터리
  • 국내드라마
  • 해외드라마
  • 예능
  • 팟케스트
  • 방송프로그램
  • 무한도전
  • 더지니어스
  • 개그콘서트
  • 런닝맨
  • 나가수
  • 디지털
  • 컴퓨터
  • 프로그래머
  • IT
  • 안티바이러스
  • 애플
  • 안드로이드
  • 스마트폰
  • 윈도우폰
  • 심비안
  • 스포츠
  • 스포츠
  • 축구
  • 야구
  • 농구
  • 바둑
  • 야구팀
  • 삼성
  • 두산
  • NC
  • 넥센
  • 한화
  • SK
  • 기아
  • 롯데
  • LG
  • KT
  • 메이저리그
  • 일본프로야구리그
  • 게임1
  • 플래시게임
  • 게임토론방
  • 엑스박스
  • 플레이스테이션
  • 닌텐도
  • 모바일게임
  • 게임2
  • 던전앤파이터
  • 마비노기
  • 마비노기영웅전
  • 하스스톤
  • 히어로즈오브더스톰
  • gta5
  • 디아블로
  • 디아블로2
  • 피파온라인2
  • 피파온라인3
  • 워크래프트
  • 월드오브워크래프트
  • 밀리언아서
  • 월드오브탱크
  • 블레이드앤소울
  • 검은사막
  • 스타크래프트
  • 스타크래프트2
  • 베틀필드3
  • 마인크래프트
  • 데이즈
  • 문명
  • 서든어택
  • 테라
  • 아이온
  • 심시티5
  • 프리스타일풋볼
  • 스페셜포스
  • 사이퍼즈
  • 도타2
  • 메이플스토리1
  • 메이플스토리2
  • 오버워치
  • 오버워치그룹모집
  • 포켓몬고
  • 파이널판타지14
  • 배틀그라운드
  • 기타
  • 종교
  • 단어장
  • 자료창고
  • 운영
  • 공지사항
  • 오유운영
  • 게시판신청
  • 보류
  • 임시게시판
  • 메르스
  • 세월호
  • 원전사고
  • 2016리오올림픽
  • 2018평창올림픽
  • 코로나19
  • 2020도쿄올림픽
  • 게시판찾기
  • 오유인페이지
    개인차단 상태
    귀두님의
    개인페이지입니다
    가입 : 12-07-30
    방문 : 1653회
    닉네임변경 이력
    회원차단
    회원차단해제
    게시물ID : programmer_18787
    작성자 : 귀두
    추천 : 0
    조회수 : 728
    IP : 210.125.***.25
    댓글 : 2개
    등록시간 : 2016/10/20 23:27:22
    http://todayhumor.com/?programmer_18787 모바일
    jquery 달력 질문드립니다!!
    옵션
    • 본인삭제금지
    /* -- DO NOT REMOVE --
     * jQuery DCalendar 1.1 and DCalendar Picker 1.3 plugin
     * 
     * Author: Dionlee Uy
     *
     * Date: Sat Mar 2 2013
     *
     * @requires jQuery
     * -- DO NOT REMOVE --
     */
    if (typeof jQuery === 'undefined') { throw new Error('DCalendar.Picker: This plugin requires jQuery'); }
     
    +function ($) {

    Date.prototype.getDays = function() { return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate(); };
    var months = ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
    short_months = ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
    daysofweek = ['일요일','월요일','화요일','수요일','목요일','금요일','토요일'],

    DCalendar = function(elem, options) {
       this.calendar = $(elem);
    this.today = new Date(); //system date

    //current selected date, default is today if no value given
    if(this.calendar.prev().val() === '') {
    this.date = new Date();
    } else {
    var dateObj = this.reformatDate(this.calendar.prev().val());
    this.date = isNaN(parseInt(dateObj.m)) ? new Date(dateObj.m + " " + dateObj.d + ", " + dateObj.y) : new Date(dateObj.y, dateObj.m - 1, dateObj.d);
    }

    this.viewMode = 'days';
    this.options = options;
    this.selected = (this.date.getMonth() + 1) + "/" + this.date.getDate() + "/" + this.date.getFullYear();
    this.minDate = this.calendar.prev().data('mindate');
    this.maxDate = this.calendar.prev().data('maxdate');
    if(options.mode === 'calendar')
    this.tHead = $('<thead><tr><th id="prev">&lsaquo;</th><th colspan="5" id="currM"></th><th id="next">&rsaquo;</th></tr><tr><th>일</th><th>월</th><th>화</th><th>수</th><th>목</th><th>금</th><th>토</th></tr></thead>');
    else if (options.mode === 'datepicker')
    this.tHead = $('<thead><tr><th id="prev">&lsaquo;</th><th colspan="5" id="currM"></th><th id="next">&rsaquo;</th></tr><tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr></thead>');
    this.tHead.find('#currM').text(this.today.getFullYear() + " " + months[this.today.getMonth()]);  
    this.calendar.prepend(this.tHead);
    var that = this;

    this.calendar.on('click', '#next', function() { initCreate('next'); })
    .on('click', '#prev', function() { initCreate('prev'); })
    .on('click', '#today', function() {
    that.viewMode = 'days';
    var curr = new Date(that.date),
    sys = new Date(that.today);
    if(curr.toString() != sys.toString()) { that.date = sys; }
    that.create('days');
    }).on('click', '.date, .pMDate, .nMDate', function() {
    location.href='./calendar_form.php'
    var isPrev = $(this).hasClass('pMDate'),
    isNext = $(this).hasClass('nMDate'),
    sdate = $(this).text(),//////////////////////////////날짜 클릭시 클릭한 날짜변환
    cmonth = that.date.getMonth(),
    cyear = that.date.getFullYear(),
    min = that.minDate === "today" ? new Date(that.today.getFullYear(), that.today.getMonth(), that.today.getDate()) : new Date(that.minDate),
                    max = that.maxDate === "today" ? new Date(that.today.getFullYear(), that.today.getMonth(), that.today.getDate()) : new Date(that.maxDate);
    /* Calculate year */
    if(isPrev) { cyear = (cmonth === 0 ? cyear - 1 : cyear); }
    else if(isNext) { cyear = (cmonth + 2 === 13 ? cyear + 1 : cyear); }
    /* Calculate month */
    if(isPrev) { cmonth = (cmonth === 0 ? '12' : cmonth); }
    else if (isNext) { cmonth = (cmonth + 2 === 13 ? '1' : cmonth + 2); }
    else { cmonth = cmonth + 1; }

    // Selected date
    var selected = new Date(cyear, cmonth - 1, sdate);

    console.log(cmonth);
    console.log(selected);
    if ((that.minDate && selected < min) || (that.maxDate && selected > max)) return;

    that.selected = cyear + '.' + cmonth + '.' + sdate;

    if(that.options.mode === 'datepicker') {
    that.calendar.find('td').removeClass('selected');
    $(this).addClass('selected');
    }

    that.selectDate();
    return true;
    }).on('click', '#currM', function(){
    that.viewMode = 'months';
    that.create(that.viewMode);
    }).on('click', '.month', function(e){
    that.viewMode = 'days';
    var curr = new Date(that.date), y = that.calendar.find('#currM').text();
    curr.setMonth($(e.currentTarget).attr('num'));
    that.date = curr;
    that.create(that.viewMode);
    });
    function initCreate(o){
    var curr = new Date(that.date),
    currMonth = curr.getMonth(),
    currYear = curr.getFullYear();
    curr.setDate(1);
    if(that.viewMode === 'days') {
    curr.setMonth(currMonth + (o === 'next' ? 1 : -1));
    } else {
    curr.setFullYear(currYear + (o === 'next' ? 1 : - 1));
    }
    that.date = curr;
    that.create(that.viewMode);
    }

    this.create(this.viewMode);
    }

    DCalendar.prototype = {

    constructor : DCalendar, 

    setDate : function() {
    var that = this,
    dateObj = that.reformatDate(that.calendar.prev().val()),
    value = isNaN(parseInt(dateObj.m)) ? new Date(dateObj.m + " " + dateObj.d + ", " + dateObj.y) : new Date(dateObj.y, dateObj.m - 1, dateObj.d);

    that.selected = value.getFullYear() + "/" + (value.getMonth() + 1) + "/" +value.getDate();
    that.selectDate();
    that.date = value;
    that.create(that.viewMode);
    },

    selectDate : function () {
    var that = this,
    newDate = that.formatDate(that.options.format),
    e = $.Event('selectdate', {date: newDate});

    that.calendar.trigger(e);
    },

    reformatDate : function (date) {
    var that = this,
    format = that.options.format;

    return {
    m: date.substring(format.indexOf('m'), format.lastIndexOf('m') + 1),
    d: date.substring(format.indexOf('d'), format.lastIndexOf('d') + 1),
    y: date.substring(format.indexOf('y'), format.lastIndexOf('y') + 1)
    };
    },

    formatDate : function (format) {
    var that = this;
    var d = new Date(that.selected), day = d.getDate(), m = d.getMonth(), y = d.getFullYear();
    return format.replace(/(yyyy|yy|mmmm|mmm|mm|m|dd|d)/gi, function (e) {
    switch(e.toLowerCase()){
    case 'd': return day;
    case 'dd': return (day < 10 ? "0"+day: day);
    case 'm': return m+1;
    case 'mm': return (m+1 < 10 ? "0"+(m+1): (m+1));
    case 'mmm': return short_months[m];
    case 'mmmm': return months[m];
    case 'yy': return y.toString().substr(2,2);
    case 'yyyy': return y;
    }
    });
    },

    create : function(mode){
    var that = this, cal = [], 
    tBody = $('<tbody></tbody>'), 
    d = new Date(that.date.getFullYear(), that.date.getMonth(), that.date.getDate()),
    days = that.date.getDays(),
    day = 1, nStartDate = 1,
    selDate = that.selected.split('/'),
    selected = new Date(selDate[2], selDate[0] -1, selDate[1]),
    today = new Date(that.today.getFullYear(), that.today.getMonth(), that.today.getDate()),
    min = that.minDate === "today" ? today : new Date(that.minDate),
                    max = that.maxDate === "today" ? today : new Date(that.maxDate);

    that.calendar.empty();
    if(mode === "days") {
    if(that.options.mode === 'calendar') {
    that.tHead = $('<thead><tr><th id="prev">&lsaquo;</th><th colspan="5" id="currM"></th><th id="next">&rsaquo;</th></tr><tr><th>일</th><th>월</th><th>화</th><th>수</th><th>목</th><th>금</th><th>토</th></tr></thead>');
    } else if (that.options.mode === 'datepicker') {
    that.tHead = $('<thead><tr><th id="prev">&lsaquo;</th><th colspan="5" id="currM"></th><th id="next">&rsaquo;</th></tr><tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr></thead>');
    }
    that.tHead.find('#currM').text(that.date.getFullYear()+ "년" + " " + months[that.date.getMonth()]);
    that.calendar.append(that.tHead);

    for(var i = 1; i <= 6; i++){
    var temp = [$('<td></td>'),$('<td></td>'),$('<td></td>'),$('<td></td>'),$('<td></td>'),$('<td></td>'),$('<td></td>')];

    while(day <= days){
    d.setDate(day)
    var dayOfWeek = d.getDay();

    if(d.getTime() == today.getTime()) temp[dayOfWeek].attr('id', 'currDay');

    if ((that.minDate && d < min) || (that.maxDate && d > max)) temp[dayOfWeek].addClass('disabled');

    if(that.options.mode === 'datepicker' && d.getTime() == selected.getTime()) temp[dayOfWeek].addClass('selected');

    if(i === 1 && dayOfWeek === 0) break; 
    else if(dayOfWeek < 6) temp[dayOfWeek].html('<span>'+(day++)+'</span>').addClass('date');
    else {
    temp[dayOfWeek].html('<span>'+(day++)+'</span>').addClass('date');
    break;
    }
    }
    /* For days of previous and next month */
    if (i === 1 || i > 4) {
    // First week
    if (i === 1) {
    var p = new Date(that.date.getFullYear(), that.date.getMonth() - 1, 1),
    pMonth = p.getMonth(), pDays = p.getDays();

    for (var a = 6; a >= 0; a--) {
    if (temp[a].text() === ''){
    p.setDate(pDays);

    temp[a].html('<span>' + (pDays--)+ '</span>').addClass('pMDate');
    if ((that.minDate && p < min) || (that.maxDate && p > max)) temp[a].addClass('disabled');
    if (that.options.mode === 'datepicker' && p.getTime() == selected.getTime()) temp[a].addClass('selected');
    }
    }
    // Last week
    else if (i > 4) {
    var nextMonth = new Date(that.date.getFullYear(), that.date.getMonth() + 1, 1);
    for (var a = 0; a <= 6; a++) {
    if (temp[a].text() === ''){

    nextMonth.setDate(nStartDate);

    temp[a].html('<span>' + (nStartDate++) + '</span>').addClass('nMDate');
    if ((that.minDate && nextMonth < min) || (that.maxDate && nextMonth > max)) temp[a].addClass('disabled');
    if (that.options.mode === 'datepicker' && nextMonth.getTime() == selected.getTime()) temp[a].addClass('selected');
    }
    }
    }
    }
    cal.push(temp);
    }

    $.each(cal, function(i, v){
    var row = $('<tr></tr>'), l = v.length;
    for(var i = 0; i < l; i++) { row.append(v[i]); }
    tBody.append(row);
    });

    var sysDate = "Today: " + daysofweek[that.today.getDay()] + ", " + months[that.today.getMonth()] + " " + that.today.getDate() + ", " + that.today.getFullYear();
    tBody.append('<tr><td colspan="7" id="today">' + sysDate + '</td></tr>').appendTo(that.calendar);
    } else {
    this.tHead = $('<thead><tr><th id="prev">&lsaquo;</th><th colspan="2" id="currM"></th><th id="next">&rsaquo;</th></tr>');
    that.tHead.find('#currM').text(that.date.getFullYear());
    that.tHead.appendTo(that.calendar);
    var currI = 0;
    for (var i = 0; i < 3; i++) {
    var row = $('<tr></tr>');
    for (var x = 0; x < 4; x++) {
    var col = $('<td align="center"></td>');
    var m = $('<span class="month" num="' + currI + '">' + short_months[currI] + '</span>');
    col.append(m).appendTo(row);
    currI++;
    }
    tBody.append(row);
    }
    var sysDate = "Today: " + daysofweek[that.today.getDay()] + ", "+ months[that.today.getMonth()] + " " + that.today.getDate() + ", " + that.today.getFullYear();
    tBody.append('<tr><td colspan="4" id="today">' + sysDate + '</td></tr>').appendTo(that.calendar);
    }
    }
    }

    /* DEFINITION FOR DCALENDAR */
    $.fn.dcalendar = function(opts){
    return $(this).each(function(index, elem){
    var that = this;
      var $this = $(that),
      data = $(that).data('dcalendar'),
      options = $.extend({}, $.fn.dcalendar.defaults, $this.data(), typeof opts === 'object' && opts);
      if(!data){
      $this.data('dcalendar', (data = new DCalendar(this, options)));
      }
      if(typeof opts === 'string') data[opts]();
    });
    }

    $.fn.dcalendar.defaults = {
    mode : 'calendar',
    format: 'mm.dd.yyyy',
    };

    $.fn.dcalendar.Constructor = DCalendar;

    /* DEFINITION FOR DCALENDAR PICKER */
    $.fn.dcalendarpicker = function(opts){
    return $(this).each(function(){
    var that = $(this),
    hovered = false, selectedDate = false,
    cal = null;

    if(typeof opts === 'string') {
    var data = that.next('.calendar').data('dcalendar');
    data[opts]();
    } else {
    cal = $('<table class="calendar"></table>');
    that.wrap($('<div class="datepicker" style="display:inline-block;position:relative;"></div>'));
    cal.css({
    position:'absolute',
    left:0, display:'none',
    'box-shadow':'0 4px 6px 1px rgba(0, 0, 0, 0.14)',
    width:'230px',
    }).appendTo(that.parent());
    if(opts){
    opts.mode = 'datepicker';
    cal.dcalendar(opts);
    } else{
    cal.dcalendar({mode: 'datepicker'});
    }
    cal.hover(function(){
    hovered = true;
    }, function(){
    hovered = false;
    }).on('click', function(){
    if(!selectedDate)
    that.focus();
    else {
    selectedDate = false;
    $(this).hide();
    }
    }).on('selectdate', function(e){
    that.val(e.date).trigger('onchange');
       that.trigger($.Event('dateselected', {date: e.date, elem: that}));
    selectedDate = true;
    });
    that.on('keydown', function(e){ if(e.which) return false; })
    .on('focus', function(){
    $('.datepicker').find('.calendar').not(cal).hide();
    cal.show();
    })
    .on('blur', function(){ if(!hovered) cal.hide(); });
    }
    });
    }

    }(jQuery);
    날짜 클릭시 클릭된 날짜 변환
    제가 달력으로 일정관리하는 프로그램을 짜고있는데요 이부분이 날짜 하나하나 클릭하는 소스같은데
    제가 궁금한건 날짜 하나를 클릭했을때 일정관리 하는 폼으로 넘어가고 그폼에서 디비로 일정이 저장이 되는데 
    그 클릭한 날짜에 일정을 뿌리고싶은데 어떻게해야할지 모르겠어요
    일단 sdate가 날짜 클릭시 클릭된 날짜 변환 해주는 변수 같습니다.
    사실 궁극적인 질문은 이 달력이 테이블 형태로 되어있는데 날짜가 있는 td를 못찾겠습니다. 한줄씩 지워가면서 해봐도 
    못찾겠어서 이렇게 무례하지만 질문드립니다...

    이 게시물을 추천한 분들의 목록입니다.
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

    죄송합니다. 댓글 작성은 회원만 가능합니다.

    번호 제 목 이름 날짜 조회 추천
    57
    이거 왜이런건가요 도와주세요ㅠㅠ [2] 본인삭제금지 귀두 17/05/10 23:11 55 1
    56
    다이어트 한달반 됐는데 바나나 너무 맛있네요... 귀두 17/04/16 18:16 80 1
    55
    다이어트 한달간 인바디 변화!! [1] 귀두 17/04/03 23:54 83 4
    54
    지금 다이어트 잘하고있는거 맞겠죠... [4] 귀두 17/03/28 23:21 39 5
    53
    다이어트 식단 질문좀 드립니다!! [8] 본인삭제금지 귀두 17/03/13 22:57 64 0
    52
    주짓수 질문드립니다!! [3] 본인삭제금지 귀두 17/02/13 20:17 52 0
    51
    컴게님들 궁금한게 있는데 귀두 17/02/01 20:34 34 0
    50
    저 혹시 pc카톡 대화내용을 모바일로 옮기는방법 아시는분 없나요 ㅠㅠ [3] 본인삭제금지 귀두 17/01/31 20:32 45 0
    49
    크롬으로 액티브x 설치할수있는 방법없나요?? [2] 본인삭제금지 귀두 16/12/29 18:24 54 0
    48
    현 실무에서 자바개발을 하고게신 분들에게 질문드립니다! [1] 본인삭제금지 귀두 16/12/10 17:34 40 0
    47
    phonegap node.js cordova error 오류 질문드립니다 [1] 본인삭제금지 귀두 16/12/03 12:07 20 0
    46
    하이브리드앱 질문드립니다!! [3] 본인삭제금지 귀두 16/11/30 22:59 20 0
    45
    css 질문드립니다!! [2] 본인삭제금지 귀두 16/11/21 03:03 21 0
    44
    핸드폰 분실시 질문드립니다! [3] 본인삭제금지 귀두 16/11/20 16:10 26 0
    43
    안녕하세요 개발자를 꿈꾸고있는 학생입니다. [10] 본인삭제금지 귀두 16/11/16 13:13 87 1
    42
    jquery 질문드립니다. [1] 본인삭제금지 귀두 16/10/27 17:17 40 0
    41
    php 상대바 id 값 가져오기 질문입니다. [7] 귀두 16/10/23 16:02 38 0
    40
    php 공부중인데 질문드립니다. [20] 본인삭제금지 귀두 16/10/22 19:59 44 0
    jquery 달력 질문드립니다!! [2] 본인삭제금지 귀두 16/10/20 23:27 22 0
    38
    선택약정 할인 위약금 질문드립니다!! [6] 본인삭제금지 귀두 16/09/30 19:26 44 0
    37
    ㅅㄷㄹ 에서 안사면 호갱인가요...?? [3] 본인삭제금지 귀두 16/09/29 20:27 96 0
    36
    할부원금 질문드립니다!! [3] 본인삭제금지 귀두 16/09/27 19:08 41 0
    35
    폰알못이 핸드폰 기기변경 으로 바꾸려고하는데 질문드립니다!! [7] 본인삭제금지 귀두 16/09/24 19:45 45 0
    34
    선택약정할인제도(단말기자급제) 질문드립니다!! [1] 본인삭제금지 귀두 16/08/25 14:35 29 0
    33
    css 질문드립니다!! [5] 본인삭제금지 귀두 16/06/12 15:42 27 0
    32
    php 회원정보 불러오기 질문드립니다.!! 본인삭제금지 귀두 16/05/22 10:43 26 0
    31
    안드로이드 계산기 질문드립니다. [17] 본인삭제금지 귀두 16/05/14 03:02 29 2
    30
    html 쌩초보 table태그 질문드립니다! [8] 본인삭제금지 귀두 16/03/30 17:26 37 0
    29
    30~40만원 선에서 자전거 추천부탁드릴게요!! [19] 본인삭제금지 귀두 16/03/28 18:55 83 4/7
    28
    html table태그 질문드립니다! [2] 본인삭제금지 귀두 16/03/25 18:35 32 0
    [1] [2]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈