728x90
반응형

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
addloadEvent(function(){
            fileFields();
        });
        
        function Fields(){
            var x = document.getElementById('fileup');
            var imglist = document.getElementById("imglist");
            var i = parseInt(id.substing(3));
            document.allimglist.innerHTML += val+"<br/>";
            parseFloat(this.lastChild.id)+1
            var cnt =0;
            var lastid;
            //element중 <input type='file'인 element의 길이를 구하고 마지막 element의 id를 얻는다.
            //마지막 id+1로 새로 생성되는 element의 id로 정의
            for(i=0; j< document.f.elements.length; j++){
                if(document.f.elements[j].type=="file"){
                    cnt++;
                    lastid = parseInt(document.f.elements[j].id.substring(3));
                }
            }
            var i;
            if(lastid !=undefined){
                i=lastid+1;                
            }else{
                i = 1;
            }
            if(cnt>4){
                alert('최대 5개까지 업로드할수 있습니다.');
                return;
            }else if(i==1 || (document.getElementById("pat"+lastid)!=null && documnet.getElementById("pat"+lastid).value!='')){
                
            } else{
                var div = document.createElement("div");
                div.setAttribute("id"+"div"+i);
                input = document.createElement("input");
                input.setAttribute("type""file");
                input.setAttribute("name""imgPath");
                input.setAttribute("id","pat"+i);
                input.setAttribute("size",60);
                input.setAttribute("maxlength",200);
                var can = document.createElement("input");
                can.setAttribute("type","button");
                can.setAttribute("id","can"+i);
                can.onclick=function(evt){delfile(this.id);};
                //onchange ="javascript:fileFields(this.id)"
                var br =documnet.createElement("<br/>");
                var ref=document.createElement("input");
                ref.setAttribute("type","text");
                ref.setAttribute("name","imgRef");
                ref.setAttribute("id","ref"+i);
                ref.setAttribute("size",60);
                ref.setAttribute("maxlength",250);
                div.appendChild(input);
                div.appendChild(can);
                div.appendChild(br);
                div.appendChild(ref);
                x.appendChild(div);
            }
        }
        
        function delfile(id){
            var i = parseInt(id.substring(3));
            //id가 xxx1dls element는 삭제하지 않는다/
            var x= document.getElementById('div'+i);
            var fileup = document.getElementById('fileup');
            fileup.removeChild(x);
        /* var v = document.getElementById("pat"+i);
             var y = document.getElementById("can"+i);
             var z = document.getElementById("ref"+i);
             if(v!=null&&y!=null&&z!=null){
                x.removeChild(v);    
                y.removeChild(v);
                z.removeChild(v);
            }*/
        }
        
        /*function addLoadEvent(func){
            var oldonload = window.onload;
            if(typeof window.onload !='function'){
                window.onload = func;
            }else{
                window.onload =function(){
                    if(oldonload){
                        oldonload();
                    }
                    func();
                }
            }
        }*/
        function CheckStLen(maxlen){
            var temp; //들어오는 문자값;
            var msglen;
            msglen=maxlen*2;
            I = document.f.strSumm.value.length;
            tmpstr ="";
            if(I ==0){
                
            }else{
                for(k=0;k<I;k++){
                    temp = f.strSumm.value.charAt(k);
                    if(escapte(temp).length >4){
                        msglen -=2;
                    }else{
                        msglen--;
                    }
                    if(msglen<0){
                        alert("총 영문"+(maxlen*2)+자"자 한글"+maxlen+"자 까지 작성하실 수 있습니다.");
                        document.f.strSumm.value = tmpstr;
                        break;
                    }else{
                        tmpstr += temp;
                    }
                }
            }
        }

 

728x90
반응형
블로그 이미지

nineDeveloper

안녕하세요 현직 개발자 입니다 ~ 빠르게 변화하는 세상에 뒤쳐지지 않도록 우리모두 열심히 공부합시다 ~! 개발공부는 넘나 재미있는 것~!

,