추가된 곳의 datepicker가 적용되게 하려면
본문
추가 버튼을 클릭하면 datepicker가 뜨기는 하는데, datepicker의 날짜가 처음항목으로 들어갑니다.
어떻게 하면 클릭한 곳의 datepicker로 날짜가 들어가게 할수 있을까요?
소스코드 올립니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=1400, user-scalable=yes">
<meta http-equiv="X-UA-Compatible" content="IE=Edge, chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/admin.css" />
<script type="text/javascript" src="../../js/jquery-1.11.1.js"></script>
<!-- jQuery UI -->
<link href="../../js/jquery-ui-1.11.1.custom/jquery-ui.css" rel="stylesheet">
<link href="../css/select2.min.css" rel="stylesheet">
<script src="../../js/jquery-ui-1.11.1.custom/external/jquery/jquery.js"></script>
<script src="../../js/jquery-ui-1.11.1.custom/jquery-ui.js"></script>
<script type="text/javascript" src="../../js/jquery.form.js"></script>
<!-- // jQuery UI -->
<script type="text/javascript" src="/editor/js/HuskyEZCreator.js" charset="utf-8"></script>
<script language="javascript" type="text/javascript" src="../js/common.js"></script>
<script language="javascript" type="text/javascript" src="../js/validate.js"></script>
<script language="javascript" type="text/javascript" src="../js/admin_func.js"></script>
<link rel="stylesheet" type="text/css" href="../css/dtree.css" />
<script language="javascript" type="text/javascript" src="../js/dtree.js"></script>
<script language=javascript src="../../js/common.js"></script>
<script language=javascript src="../js/select2.min.js"></script>
</head><body marginheight="0" marginwidth="0">
<script>
$(function() {
//select box 검색가능하도록
//$('.select2').select2();
$('.datepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeYear: true,
changeMonth: true,
monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
});
});
function add_info() {
var chasu_html = $('.chasu_info').html();
$('.chasu_info').append(chasu_html); //과정차수 기초정보 ~ 심사정보 추가
$(document).find('.datepicker').removeClass('hasDatepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeYear: true,
changeMonth: true,
monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
});
}
function del_info() {
}
</script>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-left:10px;padding-right:10px">
<table cellpadding="0" cellspacing="0" width="100%" border="0" style="table-layout:fixed;background:url(../images/admin/common/line_bg.gif) repeat-x bottom;">
<tr height="42">
<td width="900" style="padding-left:5px;">
<b style="font-family:Dotum, 돋움, Arial;font-size:17px;">
<div id="_ttl_"><div class="blt_new"></div><div>과정차수관리(등록)</div></div>
</b>
</td>
<td align="right">
<nobr>
<a href="../inc/main.html" target="_Main"><img src="../images/nav_home.gif" align="absmiddle" title="메인으로"></a>
<a href="javascript:location.reload()"><img src="../images/nav_reload.png" align="absmiddle" title="새로고침"></a>
<a href="javascript:window.print()"><img src="../images/nav_printer.png" align="absmiddle" title="인쇄"></a>
</td>
</tr>
</table>
<table width="900" cellpadding="0" cellspacing="0">
<tr>
<td style="padding-top:10px;padding-bottom:10px;">
<form name="form1" method="POST" >
<div id="add_btn" style="text-align:right">
<input type="button" value="추가" class="bttn" onclick="add_info();" />
</div>
<div id="chasu_wrap">
<div class="chasu_info" style="margin-top:10px">
<table class="c_tb01" cellpadding="0" cellspacing="0">
<tr>
<td class="c_th01">기초정보</td>
<td class="c_td01"></td>
</tr>
</table>
<table class="f_tb01" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
<col width="120"><col><col width="120"><col>
<tr>
<td class="f_th01">과정정보 *</td>
<td class="f_td01" colspan=3>
<select name="course_id[]" class="select2">
<option value="">-선택-</option>
<option value="32">2%의 차이를 만드는 위닝 프레젠테이션</option>
<option value="13">Fun Fun! CS경영 트렌드와 병원서비스 이야기</option>
</select>
</td>
</tr>
<tr>
<td class="f_th01">년도/기수 *</td>
<td class="f_td01" colspan=3>
<select name="class_year[]">
<option value="">-선택-</option>
<option value="2016">2016년</option>
<option value="2017">2017년</option>
<option value="2018">2018년</option>
<option value="2019">2019년</option>
<option value="2020">2020년</option>
</select>
<input type="text" name='class_prograss[]' style="width:50px" value='' onKeyup="OnlyNumber(this)">
기
<span class="desc01"> 과정정보와 년도, 기수는 중복될 수 없습니다.</span>
</td>
</tr>
<tr>
<td class="f_th01">HRDNET 회차정보</td>
<td class="f_td01" colspan=3>
<input type="text" name='hrd_course_se[]' style="width:200px" value="">
<span class="desc01"> HRD-NET 행정지원시스템 회차정보와 동일</span>
</td>
</tr>
<tr>
<td class="f_th01">수강신청기간*</td>
<td class="f_td01">
<input type="text" name='reg_start[]' class="datepicker" style="width:90px" value=''>
~
<input type="text" name='reg_end[]' class="datepicker" style="width:90px" value=''>
</td>
<td class="f_th01">학습기간 *</td>
<td class="f_td01">
<input type="text" name='startday[]' style="width:90px" class="datepicker" value=''>
~
<input type="text" name='endday[]' style="width:90px" class="datepicker" value=''>
</td>
</tr>
<tr>
<td class="f_th01">교강사 *</td>
<td class="f_td01">
<select name="tutor_id[]">
<option value="">-선택-</option>
<option value="kang001">홍길동</option>
<option value="kms90">이갑돌</option>
<option value="kshjso1957">이기자</option>
</select>
</td>
<td class="f_th01">고용보험적용여부 *</td>
<td class="f_td01">
<label><input type="radio" name="goyong_yn[]" class="ipt01" value="Y" /> 고용 </label>
<label><input type="radio" name="goyong_yn[]" class="ipt01" value="N" /> 비고용 </label>
</td>
</tr>
<tr>
<td class="f_th01">상태 *</td>
<td class="f_td01">
<label><input type="radio" name="state2[]" class="ipt01" value="W" /> 대기 </label>
<label><input type="radio" name="state2[]" class="ipt01" value="R" /> 접수 </label>
<label><input type="radio" name="state2[]" class="ipt01" value="P" /> 진행 </label>
<label><input type="radio" name="state2[]" class="ipt01" value="E" /> 종료 </label>
</td>
<td class="f_th01">수강순서 *</td>
<td class="f_td01">
<input type="text" name='sort_no[]' style="width:30px" value='' onKeyup="OnlyNumber(this)">
</td>
</tr>
</table>
<table class="c_tb01" cellpadding="0" cellspacing="0">
<tr>
<td class="c_th01">심사정보</td>
<td class="c_td01"></td>
</tr>
</table>
<table class="f_tb01" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
<col width="120"><col><col width="120"><col>
<tr>
<td class="f_th01">입과신고여부 *</td>
<td class="f_td01">
<label><input type="radio" name="ing_yn[]" class="ipt01" value="" checked /> 해당없음 </label>
<label><input type="radio" name="ing_yn[]" class="ipt01" value="Y" /> 신고 </label>
<label><input type="radio" name="ing_yn[]" class="ipt01" value="N" /> 미신고 </label>
</td>
<td class="f_th01">입과신고일 *</td>
<td class="f_td01">
<input type="text" name='ing_date[]' value="" style="width:90px" class="datepicker" >
</td>
</tr>
<tr>
<td class="f_th01">수료신고여부 *</td>
<td class="f_td01">
<label><input type="radio" name="complete_yn[]" class="ipt01" value="" checked /> 해당없음 </label>
<label><input type="radio" name="complete_yn[]" class="ipt01" value="Y" /> 신고 </label>
<label><input type="radio" name="complete_yn[]" class="ipt01" value="N" /> 미신고 </label>
</td>
<td class="f_th01">수료신고일 *</td>
<td class="f_td01">
<input type="text" name='complete_date[]' value="" style="width:90px" class="datepicker" >
</td>
</tr>
<tr>
<td align="center" colspan="4"><br><input type="button" value="삭제" class="bttn" onclick="del_info();" /></td>
</tr>
</table>
</div> <!-- chasu_info -->
</div> <!-- chasu_wrap -->
<table class="b_tb01" cellpadding="0" cellspacing="0">
<tr>
<td class="b_th01"><input type="button" value="목록" class="bttn" onclick="location.href='class_list.html';" /></td>
<td class="b_td01">
<input type="submit" value="등록" class="bttn" />
</td>
</tr>
</table>
</form>
<script type='text/javascript'>
//<![CDATA[
function __setElement(el, v, a) { if(v) v = v.replace(/__<__/g, '<').replace(/__>__/g, '>'); if(typeof(el) != 'object' && typeof(el) != 'function') return; if(v != null) switch(el.type) { case 'text': case 'hidden': case 'password': case 'file': case 'email': el.value = v; break; case 'textarea': el.value = v; break; case 'checkbox': case 'radio': if(el.value == v) el.checked = true; else el.checked = false; break; case 'select-one': for(var i=0; i<el.options.length; i++) if(el.options[i].value == v) el.options[i].selected = true; break; default: for(var i=0; i<el.length; i++) if(el[i].value == v) el[i].checked = true; el = el[0]; break; } if(typeof(a) == 'object') { if(el.type != 'select-one' && el.length > 1) el = el[0]; for(i in a) el.setAttribute(i, a[i]); } }
if(_f = document.forms['form1']) {
__setElement(_f['course_id'], null, {hname:'과정정보', required:'Y'});
__setElement(_f['class_year'], null, {hname:'년도', required:'Y'});
__setElement(_f['class_prograss'], null, {hname:'기수', required:'Y'});
__setElement(_f['reg_start'], null, {hname:'수강신청기간', required:'Y'});
__setElement(_f['reg_end'], null, {hname:'수강신청기간', required:'Y'});
__setElement(_f['startday'], null, {hname:'학습시작일', required:'Y'});
__setElement(_f['endday'], null, {hname:'학습종료일', required:'Y'});
__setElement(_f['tutor_id'], null, {hname:'교강사', required:'Y'});
__setElement(_f['goyong_yn'], 'Y', {hname:'고용보험', required:'Y'});
__setElement(_f['state2'], 'W', {hname:'상태', required:'Y'});
if(!_f.onsubmit) _f.onsubmit = function() { return validate(this); };
}
//]]>
</script>
<script>
function alertStatus() {
alert("중지 상태로 변경시 해당 회원은 로그인은 할 수 없습니다.");
}
</script>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>