/*

텍스트 필드에 값을 붙여 넣은 경우 그 값에서 공백을

콤마로 치환하는 예제.

 

If you paste a value into a text field,

Example of replacing with a comma.

*/

 

 

<html>

<head>

</head>

<link rel="stylesheet" type="text/css" charset="UTF-8" href="./theme-gray-all.css" />

 

<style type="text/css">

</style>

 

<script type="text/javascript" charset="UTF-8" src="./ext-all.js"></script>

 

<body>

 

<script language='javascript' >

 

Ext.onReady(function(){

 

  Ext.create('Ext.form.Panel', {

      title: 'Contact Info',

      width: 300,

      bodyPadding: 10,

      renderTo: Ext.getBody(),

      items: [{

          xtype: 'textfield',

          name: 'name',

          fieldLabel: 'Name',

          allowBlank: false  // requires a non-empty value

          ,

          listeners: {

            paste: {

              element: 'inputEl',

              fn: function(event, inputEl) {

               setTimeout(function(){

                 var temp1 = ( inputEl.value  ).replace(/ /g,",");

                 inputEl.value = temp1;

               },0);

              }

            }

          }

      }, {

          xtype: 'textfield',

          name: 'email',

          fieldLabel: 'Email Address',

          vtype: 'email'  // requires value to be a valid email address format

      }]

  });

    

    

});

Posted by 혜화초보
,

/*

paste event

*/



<html>

<head>


<style type="text/css">

 <!--

  #base1 {

  background-color: #F3F2F6;

  width: 10px;

  height: 10px;

  position:absolute;

  top: 200px;

  }

 //-->

 </style>


</head>


<script  language="javascript"  >

 /*

 */

 var ppp = 0;


 function init(){

   var groundDiv = document.getElementById('c2');

   groundDiv.addEventListener("paste", handler , false);   // all browsers and IE9+

   //groundDiv.attachEvent ("onpaste", handler);  // IE<9

 }

 

 function handler(){

    setTimeout(function(){

       var groundDiv = document.getElementById('c2').value;

       console.log('value:: ' + groundDiv );

    }, 0); //or 4

 }


</script>

    <body  onload="init();"   >

        <div id='base1' >

          <input type='text'  size='20'  name='c1' id='c2' >

        </div>

    </body>

</html>

'[.js] 이벤트' 카테고리의 다른 글

onClick onFocus eventListener  (0) 2017.09.08
div 에다가 클릭 이벤트 걸기  (0) 2017.09.06
Posted by 혜화초보
,


 




/*

설명 :  화면을 열고 click 클릭하면 이벤트가 등록되고

        a1 의 div 를 클릭하면 hello 콘솔창에 찍힘.


재밌는건 click 여러번 클릭하면 리스너도 여러번 등록되서

hello도 여러번 출력됨.

*/


<html>

<head>

</head>

<script  language="javascript"  >


function exe(){


  var div1 = document.getElementById("a1");

  div1.addEventListener('click', function (event) {

    console.log(' hello ~ ');   

  });

}




</script>

    <body  >

        <div  id='a1'  style="  height:80px ; padding-top:200px ;

            background-color: lightblue;

            padding-left:200px "  >

          <a href="javascript:exe();"  >  click  </a>        

        </div>

        

 

    </body>

</html>










'[.js] 이벤트' 카테고리의 다른 글

onClick onFocus eventListener  (0) 2017.09.08
붙여넣기 이벤트 처리 ctrl+v  (0) 2017.09.06
Posted by 혜화초보
,

<html>

<head>

</head>

<script  language="javascript"  >


var aa = 0;


function exe(){

  aa = setInterval("roofing_func()", 1000); //  1000 = 1초   1초마다 roofing_func 를 실행하라.~

}


function stop(){

  clearInterval(aa);    

}


function roofing_func(){

  console.log( 'a');

}


</script>

    <body  >

        <div  style="  height:80px ; padding-top:200px ; padding-left:200px "  >

          <a href="javascript:exe();"  >  click  </a>        

          &nbsp;&nbsp;

          <a href="javascript:stop();"  >  stop  </a>                  

        </div>

        

 

    </body>

</html>

'[.js] no category' 카테고리의 다른 글

base html 왁구  (0) 2019.08.03
include , 포함인지 여부  (0) 2017.09.13
정수로 casting 예제  (0) 2017.09.06
Posted by 혜화초보
,

<html>

<head>

</head>

<script  language="javascript"  >

 

function exe(){

 

  var a1 = '10.02';

  console.log( ' value: '+ a1 );

  console.log( ' value: '+   typeof( a1 ) ); //string

    

  a1 = parseInt( a1 );

  console.log( ' value: '+   typeof( a1 ) );  //number

  console.log( ' value: '+ a1 );

    

  a1 += 3.2;  

  console.log( ' value: '+ a1 );  //13.2

  console.log( ' value: '+   typeof( a1 ) ); //number

}

 

 

 

</script>

    <body  >

        <div  style="  height:80px ; padding-top:200px ; padding-left:200px "  >

          <a href="javascript:exe();"  >  click  </a>        

        </div>

        

 

    </body>

</html>

'[.js] no category' 카테고리의 다른 글

base html 왁구  (0) 2019.08.03
include , 포함인지 여부  (0) 2017.09.13
1초에 한번 함수 실행  (0) 2017.09.06
Posted by 혜화초보
,



function exe(){

   var dt = new Date();

  

   var month = dt.getMonth()+1;

   var day = dt.getDate();

   var year = dt.getFullYear();

   var result  = month + '-' + day + '-' + year;

   

   console.log(  '' + result   );  

 }


'[.js] 날짜' 카테고리의 다른 글

날짜 빼기 , 11개월전 날짜 구하기  (0) 2018.11.21
현재날짜 YYYYMMDDHHMMSS  (0) 2018.10.05
날짜 초 분 더하기 빼기  (0) 2017.09.08
이달의 마지막날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,




 




<html>

<head>

</head>

<script  language="javascript"  >

 

// 2016 , 2  값을 변수 처리 하면 됩니다.

// 2016년 2월의 마지막 일자를 리턴.

 function exe(){

     var lastDay = new Date( 2016 , 2 , 0);

     console.log(' lastDay: '+ lastDay );

 }


</script>

    <body  >

        <div  style="  height:200px ; padding-top:200px ; padding-left:200px "  >

          <a href="javascript:exe();"  >  click  </a>        

        </div>

    </body>

</html>







'[.js] 날짜' 카테고리의 다른 글

날짜 빼기 , 11개월전 날짜 구하기  (0) 2018.11.21
현재날짜 YYYYMMDDHHMMSS  (0) 2018.10.05
날짜 초 분 더하기 빼기  (0) 2017.09.08
현재 날짜 구하기  (0) 2017.09.06
Posted by 혜화초보
,

<html>

<head>


<style type="text/css">

 <!--

  #base1 {

  background-color: #F3F2F6;

  width: 10px;

  height: 10px;

  position:absolute;

  }

 

 //-->

 </style>


</head>


<script  language="javascript"  >

 

 /*  x1 , y1  (점A)   x2 , y2(점B)  두 점사이의 거리를 구하라~

 */

 

 var ppp = 0;

 

 

 function cal_exe(){

 

    var x1 = 10.3;

    var y1 = 10.3;    

    

    var x2 = 20.2;

    var y2 = 20.2;    

    

    var dis_x = x1 - x2;

    var dix_y = y1 - y2;


    result1 = Math.sqrt(Math.abs(dis_x*dis_x) + Math.abs(dix_y*dix_y));

    

    console.log( result1 );

    

 }

  


</script>

    <body    >

        <div id='base1' ></div>

   

        <div id="container">

        </div>

        

        <a href="javascript:cal_exe();"  >bbbbb</a>

    </body>


</html>



Posted by 혜화초보
,

 

 

 





<html>
<head>
<script type="text/javascript">


function rotate_exe() {
    s += 2;
    var sx = Math.cos((s)*1*deg)*r;
    var sy = Math.sin((s)*1*deg)*r;


    document.getElementById('star').style.left = Math.round(cx + r + sx  ) + 'px';
    document.getElementById('star').style.top = Math.round(cy + r + sy  ) + 'px';
}


function start_rotate() {
    r = 30;   //반지름
    deg = Math.PI/180; //degrees
    s = 0;


    document.getElementById('star' ).style.position = 'absolute';
    document.getElementById('star' ).innerHTML = '+';
    
    cx = 300;  //별이 회전하는 축의 x
    cy = 300;  //별이 회전하는 축의 y
    aa = setInterval("rotate_exe()", 50);      
}




</script>
</head>
<body onload="start_rotate();" >
  <div id="star"  style=""  ></div>
</body>
</html>

 

 

 

 

Posted by 혜화초보
,

 

 


/*
click 누르면 div를 생성해서 특정 위치에 위치시킨다.
다시 누르면 위치 시켰단 div 를 제거한다.
*/


<html>
<head>


<style type="text/css">
 <!--
  #base1 {
  background-color: #DCDAD9;
  width: 100px;
  height: 100px;
  position:absolute;
  }
 //-->
 </style>


</head>


<script  language="javascript"  >
 
 /*
 add_div 를 실행하면 base1 아이디를 갖는 div 를 생성하고
 cal 이라는 아이디를 갖는 input 박스의 위치를 구해서 그 위치로
 base1 div 를 이동시킨다. 
 */
 
 var ppp = 0;
 
 function cal_exe(){
   if( ppp == 0 )
     add_div();
   else
     remove_div();   
 }
 
 function add_div(){
    var a1 = document.createElement('div');
    a1.innerHTML = " <div id='base1' >  </div> ";
    document.body.appendChild(a1);


    ppp += 1;


    var pTag = document.getElementById("cal");
    var pTag2 = document.getElementById("base1"); 
   
    pTag2.style.top = pTag.offsetTop  + pTag.offsetHeight ;   
    pTag2.style.left = pTag.offsetLeft;   
    
 }


 function remove_div(obj){
    ppp= 0;
    var pTag2 = document.getElementById("base1"); 
    pTag2.parentNode.removeChild( pTag2 );
 }




</script>
    <body>
        <div id="container">
        </div>
        <br><br><br><br><br><br> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
        <input type='text'  id='cal'  >
        
        
        <a href="javascript:cal_exe();"  >bb</a>
    </body>


</html>
 

 

 

 

'[.js] div 의 이동' 카테고리의 다른 글

div 회전  (0) 2017.09.07
클릭 드레그 하면 따라다니는 div  (0) 2017.09.07
한 점을 기준으로 + 를 회전시킴  (0) 2017.09.06
Posted by 혜화초보
,