2024/03/07 초기화 기능 수정

This commit is contained in:
kmg 2024-03-07 18:24:26 +09:00
parent d505b57e4b
commit 27a5879ad2
2 changed files with 31 additions and 14 deletions

View File

@ -64,19 +64,18 @@
form.action = "<c:url value='/kccadr/oprtn/adultVisitEdu/instrActvtHstryMngDetail.do'/>"; form.action = "<c:url value='/kccadr/oprtn/adultVisitEdu/instrActvtHstryMngDetail.do'/>";
form.submit(); form.submit();
} }
//초기화
function fncReset(thisObj){ function fncReset(thisObj){
var targetObj = $(thisObj).closest('.list_top').find('select,input'); var targetObj = $(thisObj).closest('.list_top').find('select,input');
$.each(targetObj, function(){ $.each(targetObj, function(){
if($(this).prop('tagName') == 'SELECT'){ if ($(this).prop("tagName") == 'SELECT') {
if($(this).attr('name').indexOf('Month') != -1){ // 초기화 시 무조건 select option 첫번째 지정
$(this).val(new Date().getMonth()+1); $(this).find("option:first-child").prop("selected",true);
}else if($(this).attr('name').indexOf('Year') != -1){ } else if ($(this).attr('type') == 'radio') {
$(this).val(new Date().getFullYear()); var radioName = $(this).attr("name");
}else{ var radioFirst = $("[name="+radioName+"]")[0];
$(this).prop("selectedIndex", 0); $(radioFirst).prop("checked",true)
} } else {
}else{
$(this).val(''); $(this).val('');
} }
}); });

View File

@ -71,7 +71,7 @@
listForm.submit(); listForm.submit();
} }
function fncReset(thisObj){ /*function fncReset(thisObj){
var targetObj = $(thisObj).closest('.list_top').find('select,input'); var targetObj = $(thisObj).closest('.list_top').find('select,input');
$.each(targetObj, function(){ $.each(targetObj, function(){
if($(this).prop('tagName') == 'SELECT'){ if($(this).prop('tagName') == 'SELECT'){
@ -90,7 +90,25 @@
} }
} }
}); });
}*/
// 캘린더 및 라디오, 체크박스까지 초기화
function fncReset(thisObj){
var targetObj = $(thisObj).closest('.list_top').find('select,input');
$.each(targetObj, function(){
if ($(this).prop("tagName") == 'SELECT') {
// 초기화 시 무조건 select option 첫번째 지정
$(this).find("option:first-child").prop("selected",true)
} else if ($(this).attr('type') == 'radio') {
$(this).prop('checked',true);
} else if ($(this).attr('type') == 'checkbox') {
$(this).prop('checked',false);
} else {
$(this).val('');
} }
});
}
function fnCheckAll(){ function fnCheckAll(){
var chk = document.listForm.chk; var chk = document.listForm.chk;