123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239 |
- function SetFormValue(f, n, v, sep) {
- var f = document.forms[f];
- if(!f || !f[n]) return false;
- switch(f[n].type) {
- case 'text':
- case 'password':
- case 'hidden':
- f[n].value = v;
- break;
- case 'textarea':
- f[n].text = v;
- break;
- case 'checkbox':
- if(f[n].value == v) f[n].checked = true;
- break;
- case 'select-one':
- for(var i=0; i<f[n].options.length; i++) if(f[n].options[i].value == v) f[n].options[i].selected = true;
- break;
- default:
- if(sep) {
- var val = v.split(sep);
- for(var i=0; i<f[n].length; i++) {
- for(var j=0; j<val.length; j++) {
- if(f[n][i].value == val[j]) f[n][i].checked = true;
- }
- }
- }
- else {
- for(var i=0; i<f[n].length; i++) if(f[n][i].value == v) f[n][i].checked = true;
- }
- break;
- }
- }
- function GetFormValue(f, n) {
- var f = document.forms[f];
- if(!f || !f[n]) return false;
- switch(f[n].type) {
- case 'text':
- case 'file':
- case 'password':
- case 'hidden':
- return f[n].value;
- break;
- case 'textarea':
- return f[n].text;
- break;
- case 'checkbox':
- if(f[n].checked == true) return f[n].value;
- break;
- case 'select-one':
- for(var i=0; i<f[n].options.length; i++) {
- if(f[n].options[i].selected == true) {
- return f[n].options[i].value;
- }
- }
- break;
- default:
- var arr = new Array();
- var j = 0;
- for(var i=0; i<f[n].length; i++) {
- if(f[n][i].checked == true) {
- arr[j] = f[n][i].value;
- j++;
- }
- }
- return arr.join(",");
- break;
- }
- return false;
- }
- function MoveNext(el, next, size) {
- var len = el.value.length;
- if(len == size) {
- next.focus();
- return true;
- }
- }
- function IsNumeric(sText)
- {
- var ValidChars = "0123456789.";
- var IsNumber=true;
- var Char;
-
- for (i = 0; i < sText.length && IsNumber == true; i++) {
- Char = sText.charAt(i);
- if (ValidChars.indexOf(Char) == -1) {
- IsNumber = false;
- }
- }
- return IsNumber;
- }
- function OnlyNumber(el) {
- if(!IsNumeric(el.value)) {
- el.value = "";
- el.focus();
- }
- }
- function changeYear(element, d, num) {
- if(!element) return;
- if(!num) num = 10;
- var year = parseInt(element.value * 1);
- if(!year) year = !d ? new Date().getFullYear() : d;
- year = parseInt(year * 1);
- var pattern = /[^0-9]/;
- var add = "";
- var head = "";
- if(element.options.length > 0) {
- add = pattern.test(element.options[element.selectedIndex].text);
- head = element.options[0].value == "" ? element.options[0].text : "";
- }
- element.options.length = 0; var j = 0;
- if(head) {
- element.options[0] = new Option(head, "", false);
- j++;
- }
- for (var i=year-num; i<=year+num; i++, j++) {
- element.options[j] = new Option(i + (add ? "년" : ""), i, false);
- if (i == year) element.options[j].selected = true;
- }
- }
- function in_array(needle, haystack, strict) {
- var found = false, key, strict = !!strict;
- for (key in haystack) {
- if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
- found = true;
- break;
- }
- }
- return found;
- }
- function removeAttr(formName, keys, type) {
- var f = document.forms[formName];
- if(!f) return;
- type = !type ? "required" : type;
- var arr = keys.replace(/ +/g, "").split(",");
- for(var i=0; i<arr.length; i++) {
- if(f[arr[i]]) {
- var el = f[arr[i]];
- if (el.type != "select-one" && el.length > 1) el = el[0];
- el.removeAttribute(type);
- }
- }
- }
- function setAttr(formName, keys, type, value) {
- var f = document.forms[formName];
- if(!f) return;
- var arr = keys.replace(/ +/g, "").split(",");
- for(var i=0; i<arr.length; i++) {
- if(f[arr[i]]) {
- var el = f[arr[i]];
- if (el.type != "select-one" && el.length > 1) el = el[0];
- el.setAttribute(type, value);
- //alert(el.name + ":::" + type + ":::" + el.getAttribute(type));
- }
- }
- }
- /* ex)
- removeAttr("form1", "aa, ba, ca");
- removeAttr("form1", "aa, ba, ca", "optino");
- setAttr("form1", "aa, ba, ca", "required", "Y");
- */
- function setDisabled(element){
- if(!element)return;
- switch(element.type) {
- case 'text':
- case 'textarea':
- element.className = "input_readonly";
- element.readOnly = true;
- break;
- case 'radio':
- case 'checkbox':
- element.disabled = true;
- break;
- case "button":
- element.style.display = "none";
- break;
- default:
- if(element.length){
- for(var i=0; i<element.length; i++) {
- element.disabled = true;
- }
- }
- break;
- }
- }
- function setEnabled(element){
- if(!element)return;
- switch(element.type) {
- case 'text':
- case 'textarea':
- element.className = "label";
- element.readOnly = false;
- break;
- case 'radio':
- case 'checkbox':
- element.disabled = false;
- break;
- case "button":
- element.style.display = "";
- break;
- default:
- if(element.length){
- for(var i=0; i<element.length; i++) {
- element.disabled = false;
- }
- }
- break;
- }
- }
- /**
- * 웹표준에 따른 innerHTML 때문에 만들었다.
- * ie9과 chrom에서는 사용자가 입력한 값이 innerHTML로 읽혀 오지 않는다.
- * 사용자가 화면 상에서 입력한 값은 html의 dom에 바로 반영 되는 것이 아니여서 innerHTML로 읽히지 않는다.
- * 따라서 javascript setAttribute 또는 innerHTML 을 이용하여 직접 셋팅해주어야 한다.
- * **/
- function val2attr(element){
- if(!element)return;
- switch(element.type) {
- case 'text':
- case 'password':
- case 'hidden':
- element.setAttribute("value", element.value);
- break;
- case 'textarea':
- element.innerHTML = element.value;
- break;
- case 'radio':
- case 'checkbox':
- if(element.checked)
- element.setAttribute("checked", "true");
- break;
- case 'select-one':
- for(var i=0; i<element.options.length; i++) if(element.options[i].value == element.value) element.options[i].setAttribute("selected", "true");
- break;
- default:
- break;
- }
- }
- function setAttrValue(div){
- var div = document.getElementById(div);
- var input = div.getElementsByTagName("input");
- for(var i = 0; i < input.length; i ++){
- var element = input[i];
- val2attr(element);
- }
- var select = div.getElementsByTagName("select");
- for(var i = 0; i < select.length; i ++){
- var element = select[i];
- val2attr(element);
- }
- var textarea = div.getElementsByTagName("textarea");
- for(var i = 0; i < textarea.length; i ++){
- var element = textarea[i];
- val2attr(element);
- }
- }
- /******************
- 숫자만 입력하기
- ******************/
- function num_only(Ev){
- var evCode = (window.netscape) ? Ev.which : event.keyCode;
- if ((evCode < 48 || evCode > 57) && (evCode < 96 || evCode > 105)&& (evCode < 37 || evCode > 40) && evCode != 8 && evCode != 9 && evCode != 13 && evCode != 46 ) {
- if (window.netscape) {
- Ev.preventDefault();
- } else {
- window.event.returnValue = false;
- window.event.cancelBubble = true;
- try{
- window.event.stopPropagation();
- window.event.preventDefault();
- }catch(err){/*IE11이하에서는 작동안됨*/}
- }
- }
- }
- /******************
- 숫자만 입력하기
- ******************/
- function num_point_only(Ev){
- var evCode = (window.netscape) ? Ev.which : event.keyCode;
- if((48 <= evCode && evCode <= 57 || 96 <= evCode && evCode <= 105 || evCode == 8 || evCode == 46) ||
- evCode == 37 || evCode == 39 || evCode == 27 || evCode == 8 || evCode == 9 || evCode == 110 || evCode == 190)
- {
- return;
- }else
- {
- if (window.netscape) {
- Ev.preventDefault();
- } else {
- window.event.returnValue = false;
- window.event.cancelBubble = true;
- try{
- window.event.stopPropagation();
- window.event.preventDefault();
- }catch(err){/*IE11이하에서는 작동안됨*/}
- }
- }
- }
- /*********************************
- trim 기능
- *********************************/
- String.prototype.trim = function()
- {
- return this.replace(/(^\s*)|(\s*$)/gi, "");
- }
- /*********************************
- replaceAll 기능
- *********************************/
- String.prototype.replaceAll = function(sVal1, sVal2)
- {
- return funcReplaceStrAll(this,sVal1,sVal2);
- }
- /*********************************
- replaceAll 기능
- *********************************/
- function funcReplaceStrAll( org_str, find_str, replace_str)
- {
- var pos = 0;
- pos = org_str.indexOf(find_str);
- while(pos != -1)
- {
- pre_str = org_str.substring(0, pos);
- post_str = org_str.substring(pos + find_str.length, org_str.length);
- org_str = pre_str + replace_str + post_str;
- pos = org_str.indexOf(find_str);
- }
- return org_str;
- }
- /*************************
- 유효한 월(月)인지 확인.
- Parameter : MM(월)
- Return : true / false
- *************************/
- function isValidMonth(mm)
- {
- var m = parseInt(mm,10);
- return (m >= 1 && m <= 12);
- }
- /***************************************
- 유효한 일(日)인지 확인.
- Parameter : YYYY, MM, DD(년, 월, 일)
- Return : true / false
- ***************************************/
- function isValidDay(yyyy, mm, dd)
- {
- var m = parseInt(mm,10) - 1;
- var d = parseInt(dd,10);
- var end = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
- if ((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0)
- end[1] = 29;
- return (d >= 1 && d <= end[m]);
- }
- /***************************************
- 유효한 시간인지 확인.
- Parameter : hh(시간)
- Return : true / false
- ***************************************/
- function isValidHour(hh)
- {
- var hour = parseInt(hh,10);
- if(hour < 24)
- return true;
- else
- return false;
- }
- /***************************************
- 유효한 분인지 확인.
- Parameter : mm(분)
- Return : true / false
- ***************************************/
- function isValidMin(mm)
- {
- var min = parseInt(mm,10);
- if(min < 60)
- return true;
- else
- return false;
- }
- /**
- * 숫자인지 체크
- * true - 숫자
- * false - 숫자가 아님
- */
- function isNum(objValue)
- {
- var str="0123456789"
- if (objValue=="")
- {
- return false;
- }
- for (i=0;i<objValue.length;i++)
- {
- if (str.indexOf(objValue.charAt(i))==-1)
- {
- return false;
- }
- }
- return true;
- }
- /*
- * 유효한 날짜(Date) 인지 체크
- * Parameter : YYYYMMDD(년월일)
- * Return : true / false
- */
- function isValidDate(objValue)
- {
-
- if(!isNum(objValue) || objValue.length < 8)
- return false;
- year = objValue.substring(0, 4);
- month = objValue.substring(4, 6);
- day = objValue.substring(6, 8);
-
- if (parseInt(year, 10) >= 1900 && isValidMonth(month) && isValidDay(year, month, day))
- return true;
- return false;
- }
- /* --- 날짜 형식 (onKeyUp 이벤트) --- */
- function dateFormat(obj)
- {
- var str = obj.value.replace(/\-/gi, "");
- var leng = str.length;
- switch (leng)
- {
- case 1 :
- case 2 :
- case 3 :
- case 4 : obj.value = str; break;
- case 5 :
- case 6 : obj.value = str.substring(0, 4) + "-" + str.substring(4); break;
- case 7 :
- case 8 : obj.value = str.substring(0, 4) + "-" + str.substring(4, 6) + "-" + str.substring(6);
- break;
- }
- }
- /******************************************
- 인자로 입력된 값을 3자리 단위로 "," 추가
- ******************************************/
- function fnMakeComma()
- {
- if(event.keyCode == 37 || event.keyCode == 39)
- {
- return;
- }
-
- var num = event.srcElement.value;
- var sScale = "";
- if(event.srcElement.getAttribute("scale") != null)
- {
- sScale = event.srcElement.getAttribute("scale");
- }
-
- num = num.replaceAll(",","");
- if(num.length > 0 && num.substring(0,1) == ".")
- {
- alert("소숫점을 처음부터 기입하실수 없습니다.");
- event.srcElement.value = "";
- event.srcElement.Focus();
- return;
- }
- if(num.split(".").length > 2)
- {
- alert("소수점은 1개까지만 허용됩니다.");
- event.srcElement.value = "";
- event.srcElement.Focus();
- return;
- }
-
- var sNum = "";
- var sNum2 = "";
- var aNum;
- if(num.indexOf(".") != -1)
- {
- var aNum = num.split(".");
- sNum = aNum[0];
- sNum2 = aNum[1];
- }else
- {
- sNum = num;
- }
-
- if(sNum2 && sNum2.length > 3)
- {
- alert("소수점은 3자리까지 입력가능합니다.");
- event.srcElement.value = "";
- event.srcElement.Focus();
- return;
- }
-
- sNum = fnMakeComma2(sNum);
-
- if(num.indexOf(".") != -1)
- {
- event.srcElement.value = sNum + "." + sNum2;
- }else
- {
- event.srcElement.value = sNum;
- }
- }
- /******************************************
- 3자리 단위로 "," 추가
- ******************************************/
- function fnMakeComma2(val){
- var aNum;
- var sNum = "";
- var sNum2 = "";
-
- if(val.indexOf(".") != -1)
- {
- aNum = val.split(".");
- sNum = aNum[0];
- sNum2 = aNum[1];
- }else
- {
- sNum = val;
- }
-
- var new_num = "";
- for(i=0;i<sNum.length;i++) {
- new_num=sNum.substr(sNum.length-i-1,1) + new_num;
- if( sNum.substr(sNum.length-i-2,1) != '-' ) {
- if ( ((i+1) % 3 == 0 ) && ( ((i+1) != sNum.length) )) {
- new_num = "," + new_num ;
- }
- }
- }
-
- if(sNum2.length > 0)
- {
- return new_num + "." + sNum2;
- }else
- {
- return new_num;
- }
- }
- function makeComma(obj){
- var num = obj.value;
- num = num.replaceAll(",","");
- var aNum = num.split(".");
- if ( aNum.length > 2 ) {
- alert("소수점은 1개까지만 허용됩니다.");
- obj.select();
- return;
- }
- num = aNum[0];
- new_num = "";
- num = num + new_num;
- for(i=0;i<num.length;i++) {
- new_num=num.substr(num.length-i-1,1) + new_num;
- if( num.substr(num.length-i-2,1) != '-' ) {
- if ( ((i+1) % 3 == 0 ) && ( ((i+1) != num.length) )) {
- new_num = "," + new_num ;
- }
- }
- }
- if (aNum.length > 1){
- obj.value = new_num + "." + aNum[1];
- }else{
- obj.value = new_num;
- }
- }
- /***************************
- 버림
- ***************************/
- function getFloor(nVal, nLen)
- {
- var sVal = nVal + "";
-
- var aNum;
- var sNum = "";
- var sNum2 = "";
- if(sVal.indexOf(".") != -1)
- {
- aNum = sVal.split(".");
- sNum = aNum[0];
- sNum2 = aNum[1];
- }else
- {
- sNum = sVal;
- }
-
- if(sNum2.length > nLen)
- {
- sNum2 = sNum2.substring(0,nLen);
-
- var nNum3 = Number("0."+sNum2);
- var sNum3 = (nNum3+"").replaceAll("0.","");
- sNum2 = sNum3;
- }
-
- var sRtnVal = "";
-
- sRtnVal = sNum;
- if(sNum2.length > 0)
- {
- sRtnVal = sRtnVal + "." + sNum2;
- }
- return Number(sRtnVal);
- }
- // 금액 입력시 한글로 표시
- function fSetKoreanMoney(inputVal, displayClass)
- {
- var koreanMoney = "";
- var numVal = trimComma(inputVal);
- if ( (numVal != "") && isIntNum(numVal) )
- {
- koreanMoney = "一金 " + num2han(numVal) + "원整";
- }
- //document.getElementById(displayId).innerHTML = koreanMoney;
- replaceInput(koreanMoney,displayClass,__html);
- return;
- }
- // 금액 입력시 한글로 표시
- function fSetKoreanMoney2(inputVal, displayClass)
- {
- var koreanMoney = "";
- var numVal = trimComma(inputVal);
-
- if ( (numVal != "") )
- {
- koreanMoney = "一金 " + num2han2(numVal);
- }
-
- //document.getElementById(displayId).innerHTML = koreanMoney;
- replaceInput(koreanMoney,displayClass,__html);
- return;
- }
- /**
- * 숫자를 한글로
- */
- function num2han(num){
- var i, j=0, k=0;
- var han1 = new Array("","일","이","삼","사","오","육","칠","팔","구");
- var han2 = new Array("","만","억","조","경","해","시","양","구","간");
- var han3 = new Array("","십","백","천");
- var result="", hangul = num + "", pm = "";
- var str = new Array(), str2="";
- var strTmp = new Array();
- if(parseInt(num)==0) return "영"; //입력된 숫자가 0일 경우 처리
- if(hangul.substring(0,1) == "-"){ //음수 처리
- pm = "감 ";
- hangul = hangul.substring(1, hangul.length);
- }
- if(hangul.length > han2.length*4) return "too much number"; //범위를 넘는 숫자 처리 자리수 배열 han2에 자리수 단위만 추가하면 범위가 늘어남.
- for(i=hangul.length; i > 0; i=i-4){
- str[j] = hangul.substring(i-4,i); //4자리씩 끊는다.
- for(k=str[j].length;k>0;k--){
- strTmp[k] = (str[j].substring(k-1,k))?str[j].substring(k-1,k):"";
- strTmp[k] = han1[parseInt(strTmp[k])];
- if(strTmp[k]) strTmp[k] += han3[str[j].length-k];
- str2 = strTmp[k] + str2;
- }
- str[j] = str2;
- //if(str[j]) result = str[j]+han2[j]+result;
- //4자리마다 한칸씩 띄워서 보여주는 부분. 우선은 주석처리
- //result = (str[j])? " "+str[j]+han2[j]+result : " " + result;
- result = (str[j])? " "+str[j]+han2[j]+result : " " + result;
- j++; str2 = "";
- }
- return pm + result; //부호 + 숫자값
- }
- /**
- * 숫자를 한글로
- */
- function num2han2(num){
- var i, j=0, k=0;
- var han1 = new Array("","일","이","삼","사","오","육","칠","팔","구");
- var han4 = new Array("영","일","이","삼","사","오","육","칠","팔","구");
- var han2 = new Array("","만","억","조","경","해","시","양","구","간");
- var han3 = new Array("","십","백","천");
- var result="", hangul = num + "", pm = "" , sosu = "";
- var str = new Array(), str2="", str3 = new Array(), str4 = "";
- var strTmp = new Array();
-
- if(parseInt(num)==0) return "영"; //입력된 숫자가 0일 경우 처리
- if(hangul.substring(0,1) == "-"){ //음수 처리
- pm = "감 ";
- hangul = hangul.substring(1, hangul.length);
- }
- if(hangul.length > han2.length*4) return "too much number"; //범위를 넘는 숫자 처리 자리수 배열 han2에 자리수 단위만 추가하면 범위가 늘어남.
-
- var digit = hangul.indexOf('.');
- if(digit > 0){
- sosu = hangul.substring(digit, hangul.length);
- hangul = hangul.substring(0, digit);
- }
-
- for(i=hangul.length; i > 0; i=i-4){
- str[j] = hangul.substring(i-4,i); //4자리씩 끊는다.
- for(k=str[j].length;k>0;k--){
- strTmp[k] = (str[j].substring(k-1,k))?str[j].substring(k-1,k):"";
- strTmp[k] = han1[parseInt(strTmp[k])];
- if(strTmp[k]) strTmp[k] += han3[str[j].length-k];
- str2 = strTmp[k] + str2;
- }
- str[j] = str2;
- //if(str[j]) result = str[j]+han2[j]+result;
- //4자리마다 한칸씩 띄워서 보여주는 부분. 우선은 주석처리
- //result = (str[j])? " "+str[j]+han2[j]+result : " " + result;
- result = (str[j])? " "+str[j]+han2[j]+result : " " + result;
-
- j++; str2 = "";
- }
-
- if(sosu.length > 0 ){
- for(i= sosu.length; i > 1; i--){
- str3[j] = sosu.substring(i-1, i);
- for(k=str3[j].length; k>0 ;k--){
- strTmp[k] = (str3[j].substring(k-1,k))?str3[j].substring(k-1,k):"";
- str4 = han4[parseInt(strTmp[k])] + str4 ;
- }
- }
- str4 = "점"+ str4;
- }
-
- return pm + result + str4; //부호 + 숫자값
- }
- // 금액인지
- function isIntNum(objValue)
- {
- var str="-0123456789"
- if (objValue=="")
- {
- return false;
- }
- for (i=0;i<objValue.length;i++)
- {
- if (str.indexOf(objValue.charAt(i))==-1)
- {
- return false;
- }
- }
- return true;
- }
- /**
- * 문자열에서 Comma(,) 삭제
- *
- */
- function trimComma(inString)
- {
- var len = inString.length;
- var ch, outString = "c";
-
- for (i=1; i<=len; i++ )
- {
- ch = inString.substr(i-1, 1);
- if (ch == ",")
- {
- }
- else
- {
- outString = outString + ch;
- }
- }
- outlen = outString.length;
- outString = outString.substring(1,outlen);
- return outString;
- }
- /**
- * 템플릿에 있는 입력양식에서 input control을 제거한다.
- * 어느 곳에 입력하던 같은 값을 가지게 된다.
- *
- * @param inObj inputBox를 제거하려는 원본 Div 컨트롤객체
- * @param outObj inputBox를 제거한 값을 출력할 input(text, textarea) 컨트롤객체
- * @param isDebug 디버깅 화면 출력여부( 디버깅을 원하면 true, 아니면 false 또는 인자생략)
- * @return
- */
- function removeInput(inObj, outObj, isDebug)
- {
- var html = inObj.innerHTML;
- var form = document.createElement("form"); // control을 위한 임시 form
- form.innerHTML = html;
- var tmp = html.replace(/[\r|\n]/g, '');
- var style = searchStyle(html.replace(/[\r|\n]/g, '')); // innerHtml 하면 style 태그가 사라지므로 그 부분만 따로 저장한다.
- //변경계약합의서 달력 이미지 예외처리
- if(form['end_work_date_img']){
- form['end_work_date_img'].style.display="none";
- }
- if(form['calendar_sitedescdate']){
- if((form['calendar_sitedescdate'].length == "undefined") || (form['calendar_sitedescdate'].length == null)){
- form['calendar_sitedescdate'].style.display="none";
- }else{
- for(j=0; j<form['calendar_sitedescdate'].length; j++){
- form['calendar_sitedescdate'][j].style.display="none";
- }
- }
- }
- var elems = form.elements;
- for(var i=0;i<elems.length;i++){
- var aElem = elems[i];
- if( aElem.tagName == null || ( aElem.tagName.toLowerCase() != "input" && aElem.tagName.toLowerCase() != "textarea" && aElem.tagName.toLowerCase() != "select" ) ){
- continue;
- }
- // if(aElem.type.toLowerCase() != "hidden"){
- var pdf= aElem.getAttribute("pdf");
- if( pdf != null)
- {
- var id = "";
- var arrPdf = pdf.split(":");
- switch(arrPdf[0])
- {
- case "no": // 무조건 pdf 출력 안함
- var pNode = aElem.parentNode;
- while(pNode.getAttribute("id")!=arrPdf[1])
- pNode = pNode.parentNode;
- pNode.style.display = "none";
- break;
- case "op":
- if(aElem.value == "") // 값이 없는 경우 pdf 출력 안함.
- {
- var pNode = aElem.parentNode;
- while(pNode.getAttribute("id")!=arrPdf[1])
- pNode = pNode.parentNode;
- pNode.style.display = "none";
- }
- break;
- }
- }
- aElem.style.display = "none";
- if(aElem.parentNode.nodeName.toLowerCase() == "span"){
- if(aElem.value == ""){
- aElem.parentNode.innerHTML = aElem.parentNode.innerHTML + " "; // input을 삭제하면 elems.length 가 변하므로 정상적이지 않게 됨.
- }else{
- if(aElem.type.toLowerCase() == "checkbox" || aElem.type.toLowerCase() == "radio")
- {
- if(aElem.checked)
- aElem.parentNode.innerHTML = aElem.parentNode.innerHTML + '▣';
- else
- aElem.parentNode.innerHTML = aElem.parentNode.innerHTML + '□';
- }
- else if(aElem.type.toLowerCase() == "select-one")
- {
- // alert(document.getElementById(aElem.name).options.selectedIndex);
- // alert(aElem.options[document.getElementById(aElem.name).options.selectedIndex].text);
- aElem.parentNode.innerHTML = fConvertSecuStr(aElem.options[document.getElementById(aElem.name).options.selectedIndex].text);
- }
- else
- {
- // alert(aElem.parentNode.innerHTML);
- aElem.parentNode.innerHTML = aElem.parentNode.innerHTML + fConvertSecuStr(aElem.value);
- }
- }
- }
- // }
- }
- outObj.value = style + form.innerHTML;
-
- // alert(outObj.value);
- if(isDebug)
- {
- var __htmlRemoveDiv = document.createElement("div"); // control을 위한 임시 form
- __htmlRemoveDiv.innerHTML = form.innerHTML;
- document.body.insertBefore(__htmlRemoveDiv);
- }
- }
- // <style type=\"text/css\"> </style> 을 찾아 내용 가져오기
- function searchStyle(sIn)
- {
- var v_regExp = new RegExp("<STYLE[^>]*>(.*?)</STYLE>");
- if(v_regExp.test(sIn))
- {
- var v_result = v_regExp.exec(sIn);
- if(v_result != null)
- return v_result[0];
- }
- return "";
- }
- /**
- * 보안 필터에 적용받지 않도록 문자열 변환
- */
- function fConvertSecuStr(sHtmlString)
- {
- var sContents = sHtmlString;
- sContents = sContents.replaceAll("\n", "<br>");
- return sContents;
- }
- /**
- * class이름을 가지고 있는 객체의 값을 input 값으로 변경한다.
- *
- * @param inputObj 값을 입력한 객체
- * @param targetClass class ID
- * @param node 검색범위 (생략하면 document가 기본값
- * @return 대상건이 있으면 true 없으면 false
- */
- function replaceInput(inputObj, targetClass, node)
- {
- var t;
- var inputVal;
- //alert(typeof(inputObj));
- if(typeof(inputObj) == "object")
- inputVal = inputObj.value;
- else if(typeof(inputObj) == "string")
- inputVal = inputObj;
- if(node == null)
- t = getElementsByClass(targetClass);
- else
- t = getElementsByClass(targetClass, node);
- for(var i=0; i<t.length; i++)
- {
- if(t[i].tagName == "INPUT")
- t[i].value = inputVal;
- else if(t[i].tagName == "SPAN")
- {
- t[i].innerHTML = inputVal.replace("&","&");
- }else if(t[i].tagName == "TEXTAREA")
- {
- t[i].value = inputVal.replace(/<br>/gi,"\r\n");
- //t[i].value = inputVal;
- }
- }
- if(t.length > 0)
- return 1;
- else
- return 0;
- }
- // 같은 클래스명을 가진 객체를 모두 찾아낸다.
- function getElementsByClass(searchClass,node,tag)
- {
- var classElements = new Array();
- if ( node == null ) node = document;
- if ( tag == null ) tag = '*' ;
- var els = node.getElementsByTagName(tag);
- var elsLen = els.length;
- //var pattern = new RegExp("(^|s)" +searchClass+"(s|$)");
- var pattern = new RegExp("(^| )" +searchClass+"( |$)");
- for (i = 0, j = 0; i < elsLen; i++) {
- if( pattern.test(els[i].className) ) {
- classElements[j] = els[i];
- j++;
- }
- }
- return classElements;
- }
- function tabView(index) {
- // 최대 6개의 sub 양식까지만
- for(var i=0; i<=6; i++)
- {
- if(i == index)
- {
- document.getElementById("tab_"+i).className = 'tab_on';
- document.getElementById("__html_"+i).style.display = '';
- }
- else
- {
- if(document.getElementById("tab_"+i) != null)
- {
- document.getElementById("tab_"+i).className = 'tab_off';
- document.getElementById("__html_"+i).style.display = 'none';
- }
- }
- }
- }
- // 문서를 배열 컨트롤로 만든다.
- function splitHtml(f, ctrName, bRemoveInput, fileCount)
- {
-
- for(var i=0; i<fileCount; i++)
- {
- if( document.getElementById("__html_"+i) !== null )
- {
- if(document.getElementById(ctrName+"_"+i)){
- var node = document.getElementById(ctrName+"_"+i);
- node.parentNode.removeChild(node);
- }
- var __htmlCtrl = document.createElement("input"); // control을 위한 임시 form
- __htmlCtrl.setAttribute("type", "hidden");
- __htmlCtrl.setAttribute("name", ctrName);
- __htmlCtrl.setAttribute("id", ctrName+"_"+i);
- //2022.08.30 textarea 크롬에서 저장 안되는 문제 해결 : CONT_TEMPLATE에 ID(textarea_숫자)등록 후 아래와 같이 조치
- var _textarea = document.getElementById("__html_"+i).getElementsByTagName('textarea');
- for ( var j = 1; j <= _textarea.length; j++) {
- jQuery("#textarea_"+j).text( jQuery("#textarea_"+j).val());
- }
- if(bRemoveInput) // input tag의 display를 none으로 변경(pdf용)
- removeInput(document.getElementById("__html_"+i), __htmlCtrl);
- else
- __htmlCtrl.value = document.getElementById("__html_"+i).innerHTML;
- f.insertBefore(__htmlCtrl, f.lastchild);
- }
- }
- }
- /*===================================================*/
- /*
- * 기준금액의 퍼센트 금액을 set한다.
- * sAmt = 기준금액
- * rate = %
- * targetClass= 대상 class
- */
- function fSetPersentAmt(sAmt, rate, targetClass, kMoneyClass){
- if(sAmt == "" || rate == ""){
- replaceInput("", targetClass,__html);
- replaceInput("", kMoneyClass,__html);
- return;
- }
- if(sAmt == 0 && rate == 0 ){
- replaceInput("0", targetClass,__html);
- return;
- }
- sAmt = sAmt.replaceAll(",","");
- // alert(rate);
- // var cVal = Number(sAmt) * Number(rate) / 100;
- var cVal = Math.round(Number(sAmt) * (Number(rate)/100));
- cVal = getFloor(cVal,0);
- replaceInput(fnMakeComma2(cVal+""),targetClass, __html );
- if(kMoneyClass){
- fSetKoreanMoney(fnMakeComma2(cVal+""),kMoneyClass);
- }
-
- }
- /**
- * 달력 컴포넌트
- * @param obj_str
- */
- var contCalendar_year = "";
- var contCalendar_month = "";
- var contCalendar_day = "";
- function contCalendar(yyyy,MM,dd)
- {
- var info = {Format:"yyyyMMdd", CalButtons : "Close",CallBack:"contCalendar_return"};
- IBShowCalendar("",info);
- contCalendar_year = yyyy;
- contCalendar_month = MM;
- contCalendar_day = dd;
-
- }
- function contCalendar_return(value){
- var f = document.forms['form1'];
- var year = value.substring(0,4);
- var month = value.substring(4,6);
- var day = value.substring(6,8);
- replaceInput(year,contCalendar_year,__html);
- replaceInput(month,contCalendar_month,__html);
- replaceInput(day,contCalendar_day,__html);
- }
- /******************************************
- 인자로 입력된 값을 3자리 단위로 "," 추가 및 변수값에 따라서 소수점 제어
- ******************************************/
- function fnMakeComma3(sosuNum)
- {
- if(event.keyCode == 37 || event.keyCode == 39)
- {
- return;
- }
-
- if((event.keyCode == 110) && (sosuNum == 0)){
- alert("해당 통화에는 소수점 입력이 불가능 합니다.");
- event.srcElement.value = "";
- event.srcElement.focus();
- return;
- }
- var num = event.srcElement.value;
- var sScale = "";
- if(event.srcElement.getAttribute("scale") != null)
- {
- sScale = event.srcElement.getAttribute("scale");
- }
-
- num = num.replaceAll(",","");
- if(num.length > 0 && num.substring(0,1) == ".")
- {
- alert("소숫점을 처음부터 기입하실수 없습니다.");
- event.srcElement.value = "";
- event.srcElement.focus();
- return;
- }
- if(num.split(".").length > 2)
- {
- alert("소수점은 1개까지만 허용됩니다.");
- event.srcElement.value = "";
- event.srcElement.focus();
- return;
- }
-
- var sNum = "";
- var sNum2 = "";
- var aNum;
- if(num.indexOf(".") != -1)
- {
- var aNum = num.split(".");
- sNum = aNum[0];
- sNum2 = aNum[1];
- }else
- {
- sNum = num;
- }
-
- if(sNum2 && sNum2.length > sosuNum)
- {
- alert("소수점은 "+ sosuNum +"자리까지 입력가능합니다.");
- event.srcElement.value = "";
- event.srcElement.focus();
- return;
- }
-
- sNum = fnMakeComma2(sNum);
-
- if(num.indexOf(".") != -1)
- {
- event.srcElement.value = sNum + "." + sNum2;
- }else
- {
- event.srcElement.value = sNum;
- }
- }
- /*===================================================*/
- /*
- * 기준금액의 퍼센트 금액을 set한다.
- * sAmt = 기준금액
- * rate = %
- * targetClass= 대상 class
- */
- function fSetPersentAmt2(sAmt, rate, targetClass, sosuNum){
- if(sAmt == "" || rate == ""){
- replaceInput("", targetClass,__html);
- return;
- }
- if(sAmt == 0 && rate == 0 ){
- replaceInput("0", targetClass,__html);
- return;
- }
- sAmt = sAmt.replaceAll(",","");
- //var cVal = Number(sAmt) * (Number(rate)/100); 2016.9.21 1349000*70/100 계산오류로 수정
- var cVal = Number(sAmt) * Number(rate)/100 ;
- cVal = getFloor(cVal,sosuNum);
- replaceInput(fnMakeComma2(cVal+""),targetClass, __html );
- }
|