메뉴 건너뛰기

조회 수 3387 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

웹프로그램 하다가 업종 전환 한지 1년정도 되가는데 작업 하다가 필요한게 있어서 한번 만들어 봤습니다.
사용법은 제목부분의 칸 사이에 마우스를 가까이 하면 커서 모양이 바뀝니다. 그때 드래그를 하면 마우스가 이동한
거리만큼 셀의 크기가 바뀝니다.


제목 부분의 클레스 이름은 반드시 적어 주셔야 합니다. 셀의 사이즈가 변함에 따라 input 박스도 달라집니다...
그러나 사이즈가 변하는 input 박스를 남발 하면 반응 속도가
느려집니다. 또한 input 박스의 사이즈는 td의 cellpadding 보다 작아야 합니다.
주석을 달아 놨으니 이해하시는데는 별 어려움이 없을거라 생각 됩니다.
테이블을 <div> 테그 안에 넣지 않으시려면 테이블 자체의 사이즈는 지정해 주시면 안됩니다. (td)만 지정하세요
말줄임표 효과는 전에 스쿨에서 본걸로 구현해 보았습니다.

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=euc-kr">
<style>
.ellipsis {font:9pt "굴림"; width:100%; overflow:hidden; text-overflow:ellipsis; text-align:left; }
.colresize {font:9pt "굴림"; cursor:""; }
.input_box {width:expression(this.parentNode.clientWidth-8); }
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
var mousedown = false; //마우스를 누른 상태
var td = ""; //사이즈 변경할 td
var td_width; //변경할 td의 width,
var x = 0; //마우스 드레그전 가로위치
function TCstartColResize(obj){
       mousedown = true;
       td = obj;
       td_width = td.width;
       x = event.clientX;
}
function TCColResize()
{
       if (mousedown){
              var distX = event.x - x; //이동한 간격
              td.width = parseInt(td_width) + parseInt(distX);
       }
}
function TCstopColResize(){
       mousedown = false;
       td = '';
}
function cell_left(obj){//마우스가 셀의 왼쪽인지 측정
       if(event.offsetX < 5 && obj.cellIndex!=0)
              return true;
       else 
              return false;
}
function cell_right(obj){//마우스가 셀의 오른쪽인지 측정
       if(event.offsetX > obj.width-4)
              return true;
       else 
              return false;
}
//리사이즈시작
document.onmousedown = function(){
try{
       var now_mousedown = window.event.srcElement;
       if(now_mousedown.className.toUpperCase()=="COLRESIZE"){
              if( cell_left(now_mousedown) ){
                     now_mousedown = now_mousedown.parentNode.childNodes[now_mousedown.cellIndex-1];
              }else if( !cell_right(now_mousedown) ){
                     return true;//오른쪽도 왼쪽도 아니면 사이즈 조절 안함
              }
              TCstartColResize(now_mousedown);
       }
}catch(e){ return true; }
}
//리사이즈
document.onmousemove = function(){
try{
       var now_mousemove = window.event.srcElement;
       if(now_mousemove.className.toUpperCase()=="COLRESIZE" || td!=""){
              //셀의 가장자리면 마우스 커서 변경
              if( cell_left(now_mousemove) || cell_right(now_mousemove) ){
                     now_mousemove.style.cursor = "col-resize";
              }else{
                     now_mousemove.style.cursor = "";
              }
              TCColResize(now_mousemove);
       }else{
              now_mousemove.style.cursor = "";
}
}catch(e){ return true; }
}
//리사이즈종료
document.onmouseup = function(){
try{
       var now_mouseup = window.event.srcElement;
       //if(now_mouseup.className=="colResize"){
              TCstopColResize(now_mouseup);
       //}
}catch(e){ return true; }
}
//리사이즈 도중 텍스트 선택 금지
document.onselectstart = function(){
try{
if(td != ""){
return false;
}
}catch(e){ return true; }
}
//-->
</SCRIPT>
</HEAD>


<BODY>
<div style="width:100%;height:100;overflow-x:auto;overflow-y:auto">
<table width="430" border="0" cellpadding="3" cellspacing="1" bgcolor="#B8B8B8" nowrap style='table-layout:fixed'>
<tr bgcolor="#A5D4D2" align="center" height="25">
<td width="35" class="colresize">선택</td>
<td width="35" class="colresize">순번</td>
<td width="70" class="colresize">품목명</td>
<td width="30" class="colresize">수량</td>
<td width="50" class="colresize">단위</td>
<td width="70" class="colresize">날짜</td>
<td width="70" class="colresize">장소</td>
<td width="70" class="colresize">비고</td>
</tr>
<tr bgcolor="#FFFFFF" height="27" align="center">
<td><Input type="radio" name="radio"></td>
<td>1</td>
<td><input type='text' class="input_box"></td>
<td><input type='text' class="input_box"></td>
<td><select class="input_box"><option>EA</option></select></td>
<td><input type='text' class="input_box"></td>
<td><input type='text' class="input_box"></td>
<td nowrap class="ellipsis">비고 비고 비고 비고 비고 비고 비고 비고 비고</td>
</tr>
</table>
</div>
</BODY>
</HTML>


  1. No Image 28Sep
    by
    2018/09/28 Views 1528 

    엔터키 / enter key submit form

  2. No Image 21Sep
    by
    2016/09/21 Views 6033 

    엔코딩/디코딩 함수

  3. No Image 16Jan
    by 조쉬
    2019/01/16 Views 3387 

    엑셀처럼 td 사이즈 조절하기

  4. No Image 16Jan
    by
    2019/01/16 Views 1066 

    에러처리

  5. No Image 03Feb
    by
    2015/02/03 Views 7661 

    양력-음력

  6. No Image 20Aug
    by
    2021/08/20 Views 1708 

    시간 계산하기 (시/분/초/ 더하기, 빼기)

  7. No Image 12Sep
    by
    2016/09/12 Views 5833 

    스타일로 제목 자르기

  8. No Image 04Jul
    by
    2018/07/04 Views 3984 

    스마트에디터(SmartEditor)에서 textarea 유효성 체크하기

  9. 스마트 에디터 (네이버 에디터) 에디터 내에서 이미지 크기 줄이기.(리사이징)

  10. No Image 23Dec
    by
    2016/12/23 Views 6009 

    셀렉트(select) change 이벤트 (split)

  11. No Image 23Dec
    by
    2016/12/23 Views 5899 

    셀렉트(select) change href 이벤트

  12. No Image 23Dec
    by
    2016/12/23 Views 12577 

    셀렉트(select) change Ajax 이벤트

  13. No Image 28Apr
    by
    2015/04/28 Views 6614 

    선택된 데이터 부모창에 넘기기 (iframe ☞ 부모창)

  14. No Image 01Mar
    by
    2014/03/01 Views 5668 

    선택된 select 의 option 값을 다른 select로 넘겨주기

  15. No Image 28Apr
    by
    2015/04/28 Views 13538 

    선택(CheckBox) 된 Row 삭제 - 화면에서 추가된 Row

  16. No Image 01Mar
    by
    2014/03/01 Views 5513 

    샘플) top left menu

  17. No Image 01Mar
    by
    2014/03/01 Views 5715 

    새창을 띠워서 focus주기

  18. No Image 28Mar
    by
    2018/03/28 Views 6001 

    새로고침(F5) 금지

  19. 비동기 작업의 원리 (JavaScript 엔진, Web API, Task Queue, Event Loop)

  20. No Image 17Nov
    by
    2016/11/17 Views 7928 

    브라우저별 이미지 크기 변경

Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved