특정 문자열의 갯수를 확인 할수 있는 코드입니다.

match함수를 써서 확인 할수 있습니다.


var a = "가나-다라-마사-아자-차카-타파-"; 

var results = a.match(/-/g); 

if(results != null) {

console.log(results.length); // - 의 갯수를 알 수 있다.

}


자주 사용하진 않지만 가끔 필요하네요.^^

SELECT date_format(on_time, '%Y.%m.%d %k시') as 상세보기,

COUNT(if(block= 'Y', 1, null)) as 지정IP,

COUNT(if(block = 'N', 1, null)) as 차단IP,

COUNT(if(block = 'A', 1, null)) as 미지정IP

from user_log

group by 상세보기

order by 상세보기;

'개발 > DB' 카테고리의 다른 글

MS-SQL 날짜형식 SELECT  (0) 2017.08.29
오라클 사용자 비밀번호 변경 oracle password change  (0) 2017.08.10
서브쿼리 (subquery)  (0) 2017.08.01
Outer Join 정리  (0) 2017.07.31
[ MYSQL ] Access denied for user ~ (using password: YES)  (0) 2017.03.17

이렇게 나올 경우

 

1. mysql 의 데이터베이스 mysql 로 들어가서

 

User 테이블의 정보를 확인 해 본다.

 

User 컬럼의 localhost 와 %  의 비밀 번호 정보가 다르게 입력 되어 있을 수 있다.

 

다를 경우

 

update user set Password=Password('05ghcjfl') where User='smadeco' and Host='%';

 

commit;

 

FLUSH PRIVILEGES;

 

이런 식으로 재등록 해준다.

 

2. 권한이 없는 문제일 경우

 

 

GRANT ALL PRIVILEGES ON *.*TO 'smadeco'@'%' IDENTIFIED BY 'password' with GRANT OPTION;

(smadeco 는 user id임)

 

FLUSH PRIVILEGES;

 

이런 식으로 해결 해 주면 됨.

정말 개고생했습니다.......ㅠ_ㅠ 

기존에 좌표 구하는 방식은

document.getElementById("ID이름").offsetTop; 

document.getElementById("ID이름").offsetLeft; 

이런식으로 좌표를 구했다.

하지만

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

이런 DOCTYPE이 들어가는 순간 저런식으로 구하면 좌표는 0,0 이 나온다.

 

그래서 찾은 jQuery 명령어

$("#ID이름").offset().top;

$("#ID이름").offset().left;

 

이런식으로 구하니 DOCTYPE 상관없이 구해온다.^^

 

 

function getDrawableElement(inDocument) {

    if (isQuirksMode(inDocument)) {

        var body = inDocument.getElementsByTagName('body')[0];

        return body;

    }

    else {

        // standards mode

        return inDocument.documentElement;

    }

}

function $top(name) {

    var drawableElement = getDrawableElement(document);  

    var screenPosition = document.getElementsByName("secureEelement")[0].getBoundingClientRect();

    return (screenPosition.top + drawableElement.scrollTop);

}

function $left(name) {

    var drawableElement = getDrawableElement(document); 

    var screenPosition = document.getElementsByName("secureEelement")[0].getBoundingClientRect();

    return (screenPosition.left + drawableElement.scrollLeft);

}

IE에서 ActiveX 설치여부 확인하기(ActiveXObject를 이용하여)

언어/JavaScript  2012/10/25 16:51 

 

 


정의

ActiveXObject 개체

(Internet Explorer 에서만 적용된다.)

 

사용

 

var axObj = new ActiveXObject(progid);


var axObj = new ActiveXObject(servername.typename[, location]);


와 같은 방법으로 사용한다.

 

인자로 주어지는 값은 레지스트리에서 확인가능하다.

일단 제공되는 CLSID는 알고 있을것이다.

만약 모른다면,


 

IE의 추가 기능 관리에서 확인할 수 있다.

그래도 모르겠다면 벤더에 문의하면 된다.

 

찾은 CLSID로 REGEDIT에서 검색하면 아래와 같이 나온다.

상위 폴더이름이 ActiveXObject의 인자로 주어지는 progid이다.

(HKEY_CLASSES_ROOT 하위의 CLSID에서 찾으면 progid의 값이 나온다.

CLSID 폴더에 없는 경우가 있으니, 이 때는 클래스아이디로 검색해서 나오는 폴더명을 참조한다.

폴더명 뒤의 .1 은 버전이니 생략해도 된다.)

 

 

예제

 

function check(name, progid){


        var installed;

        var msg;

        try {


               var axObj = new ActiveXObject(progid);

              if(axObj){

                       installed = true;

               } else {

                       installed = false;

               }

        } catch (e) {

               installed = false;

        }


        if(installed) {

               msg = '설치됨';

        } else {

               msg = name + ' 미설치';

        }    

        return '<b>' + msg + '</b><br>';

}    

document.write(check('Adobe PDF Link Helper','AcroIEHelperShim.AcroIEHelperShimObj'));

 

간단하게 IE의 개발자 도구에서 확인할 수 있다.

$(function() {

 $("#join_confirm").click(function() {

  alert($("#frmJoin").serialize());

  

  if(status){

  $.post("${contextPath}/proc_join", 

    $("#frmJoin").serialize(),

    function(data) {

     if(data.result == 200) {

      location.href="${contextPath}/adminList";    

     } else {

      alert("가입실패");

     }

    }, 

    "json");

  }else{

   alert("중복확인해주시기 바랍니다.");

  }

 });

});

'개발 > JQUERY' 카테고리의 다른 글

jquery checkbox 체크여부/제어하기/체크갯수 구하기  (0) 2017.03.17
jQuery 좌표구하기  (0) 2017.03.17
jquery 모음  (0) 2017.03.17
jquery 한글 영어 숫자 체크  (0) 2017.03.17
jquery datatable 컬럼 동적생성  (0) 2017.03.17

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


<HTML>


<HEAD>


  <TITLE>  </TITLE>


</HEAD>


<SCRIPT LANGUAGE="JavaScript">


<!--


function GetParameter() {


    var strURL = location.search; 


    var tmpParam = strURL.substring(1).split("&");




    if (strURL.substring(1).length > 0)


    {


        var Params = new Array;


        for (i=0;i< tmpParam.length ; i++)


        {


            Params = tmpParam[i].split("=");




            alert("Params_Name = "+Params[0]);


            alert("Params_Value = "+Params[1]);


        } //for


    } //if


} //function




//함수 호출


GetParameter()


//-->


</SCRIPT>


<BODY>


  <a href="?a=1&b=1">1</a>


  <a href="?a=2&b=2">2</a>


  <a href="?a=3&b=3">3</a>


  <a href="?a=4&b=4">4</a>


  <a href="?a=5&b=5">5</a>


</BODY>


</HTML>

function sendSNS(media) {

switch(media) {

case "tw":

sendUrl = "http://twitter.com/share?url="+$("#url").val()+"&count=none&text="+$("#title").val();

window.open(sendUrl,'트위터공유하기','width=600, height=400, toolbar=no, status=no,scrollbars=yes, resizable=no, top=0, left=0');

break;

case "fa":

sendUrl = "http://www.facebook.com/sharer.php?s=100&p[url]="+$("#url").val()+"&p[title]="+$("#title").val(); 

window.open(sendUrl,'페이스북공유하기', 'width=1024, height=600, toolbar=no, status=no,scrollbars=yes, resizable=no, top=0, left=0');

break; 

}


자바스크립트에서 replaceAll 은 없다. 

정규식을 이용하여 대상 스트링에서 모든 부분을 수정해줄 수 있다. 

ex) 

str.replace("#",""); -> #를 공백으로 변경한다. 

하지만 첫번째 # 만 공백으로 변경하고 나머지는 변경이 되지 않는다. 

str.replace(/#/gi, ""); -> #를 감싼 따옴표를 슬래시로 대체하고 뒤에 gi 를 붙이면 

replaceAll 과 같은 결과를 볼 수 있다.

1. jQuery로 선택된 값 읽기

 

$("#selectBox option:selected").val();

$("select[name=name]").val();

 

2. jQuery로 선택된 내용 읽기

 

$("#selectBox option:selected").text();

 

3. 선택된 위치

 

var index = $("#test option").index($("#test option:selected"));

 

4. Addoptions to the end of a select

 

$("#selectBox").append("<option value='1'>Apples</option>");

$("#selectBox").append("<option value='2'>After Apples</option>");

 

5. Addoptions to the start of a select

 

$("#selectBox").prepend("<option value='0'>Before Apples</option>");

 

6. Replaceall the options with new options

 

$("#selectBox").html("<option value='1'>Some oranges</option><option value='2'>MoreOranges</option>");

 

7. Replaceitems at a certain index

 

$("#selectBox option:eq(1)").replaceWith("<option value='2'>Someapples</option>");

$("#selectBox option:eq(2)").replaceWith("<option value='3'>Somebananas</option>");

 

8. 지정된 index값으로 select 하기

 

$("#selectBox option:eq(2)").attr("selected", "selected");

 

9. text 값으로 select 하기

 

$("#selectBox").val("Someoranges").attr("selected", "selected");

 

10. value값으로 select 하기

 

$("#selectBox").val("2");

 

11. 지정된 인덱스값의 item 삭제

 

$("#selectBox option:eq(0)").remove();

 

12. 첫번째 item 삭제

 

$("#selectBox option:first").remove();

 

13. 마지막 item 삭제

 

$("#selectBox option:last").remove();

 

14. 선택된 옵션의 text 구하기

 

alert(!$("#selectBox option:selected").text());

 

15. 선택된 옵션의 value 구하기

 

alert(!$("#selectBox option:selected").val());

 

16. 선택된 옵션 index 구하기

 

alert(!$("#selectBox option").index($("#selectBox option:selected")));

 

17. SelecBox 아이템 갯수 구하기

 

alert(!$("#selectBox option").size());

 

18. 선택된 옵션 앞의 아이템 갯수

 

alert(!$("#selectBox option:selected").prevAl!l().size());

 

19. 선택된 옵션 후의 아이템 갯수

 

alert(!$("#selectBox option:selected").nextAll().size());

 

20. Insertan item in after a particular position

 

$("#selectBox option:eq(0)").after("<option value='4'>Somepears</option>");

 

21. Insertan item in before a particular position

 

$("#selectBox option:eq(3)").before("<option value='5'>Someapricots</option>");

 

22. Gettingvalues when item is selected

 

$("#selectBox").change(function(){

           alert(!$(this).val());

           alert(!$(this).children("option:selected").text());

});

+ Recent posts