반응형

checkbox  전체개수, 선택된 개수 구하기


선택된 개수 

   - $("input:checkbox[name=네임명]:checked").length

전체 개수

   - $("input:checkbox[name=네임명]").length


반응형
반응형

정의

type 속성이 File Upload state일 경우 accept 속성을 활용하여 서버에서 수용하는 파일의 타입에 대해 사용자 에이전트가힌트를 주도록 할 수 있습니다.

속성 값

콤마로 구분된 예약어 목록입니다. 각각의 예약어들은 다음 중 하나와 매칭되어야 합니다.(대소문자는 구분하지 않습니다.)

예약어들은 중복될 수 없습니다. 이 중복을 체크할때는 대소문자를 구분하지 않습니다. (audio/* 와 Audio/* 는 중복입니다.)

예제

예제1

<p><label>프로필 사진: <input type="file" name="profile" accept="image/*"></label></p>
Opera 11 에서 실행화면

예제1은 모든 이미지 형태의 파일을 힌트로 보여줍니다.

예제2

<p><label>동영상: <input type="file" name="profile" accept="video/mp4"></label></p>
Opera 11 에서 실행화면

예제2는 'mp4' 형식의 동영상 파일을 힌트로 보여줍니다.

예제3

<p><label>지원서: <input type="file" name="profile" accept="application/msword"></label></p>
Opera 11 에서 실행화면

예제3은 MS Word 파일을 매개변수 없는 유효한 마임 타입(valid MIME type with no parameters) 지정함으로 해당 파일을 힌트로 보여줍니다.


출처: http://html5ref.clearboth.org/html5:attribute:accept_input


반응형
반응형



얼랏창 알림에 줄바꿈이 필요할 때가 있습니다

그럴땐 아래와 같이 사용하시면 됩니다

exam) alert("안녕하세요 \n 블로그입니다");

결과 : 

안녕하세요

블로그입니다 


이런식으로 나옵니다

문자열\n문자열\n

"\n" 을 여러 개 넣으면 여러줄로 줄바꿈이 됩니다.

반응형
반응형

특정 찾아서 개수 가져오기

exam )

var  abc = "bv.dd.dd";

 var ckyn = abc.match(/[.]/g) ;


하시고


if(1 < ckyn)

{

alert(ckyn);


결과값은 : . << 점이 2개이므로 2입니다



특수문자 찾을시는 저렇게 [ ] 를 해주셔야합니다


특정 문자를 찾고싶을시에는 match(/문자/g) 하시면 됩니다



반응형
반응형

업무를 진행하다 보면 Json 형태의 데이터를 생성하여 전송하거나, 받는 경우가 종종 발생 한다.


json 형태의 데이터는 일일히 문자열로 쭉 나열하여 규칙대로 만들수도 있지만, 구조가 복잡해 지거나 데이터 양이 많을경우 사람이 일일이 만들기에는 좀 힘들다.


그래서 보통은 Java/JSP나 ASP 등과 같이 서버사이드 측에서 json을 쉽게 생성하여 HTML, Javascript 쪽에서 사용한다.



오늘은 서버사이드측이 아닌 javascript로 json 형태의 데이터를 생성하는 방법이다. 워낙 간단하니 아래 예제를 보면 쉽게 이해 할 수 

자바스크립트 내장객체인 JSON.stringfy를 이용하면 생성된 Json 객체를 String으로 변환할 수 있다.


<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript">
 
     
    $(function() {
         
        // 리스트 생성
        var testList = new Array() ;
         
 
        for(var i=1; i<=2; i++){
             
            // 객체 생성
            var data = new Object() ;
             
            data.number = i ;
            data.name = "Tester #" + i ;
             
             
            // 리스트에 생성된 객체 삽입
            testList.push(data) ;
        }
         
        // String 형태로 변환
        var jsonData = JSON.stringify(testList) ;
         
        alert(jsonData) ;
         
        /*
            출력결과 : [{"number":1,"name":"Tester #1"},{"number":2,"name":"Tester #2"}]
        */
         
    });
     
 
</script>



출처: http://fruitdev.tistory.com/190?category=568934 [과일가게 개발자]

반응형
반응형

웹 개발을 하다보면 의도하지 브라우저 캐시로 인하여 수정내용이 반영이 되지 않을때가 종종 있다.
이럴때는 해당 페이지를 몇번 새로고침하면 수정된 내용으로 나오긴 하지만, 사실 중요한 부분에서 캐쉬가 남아 
의도하지 않은 부분이 사용자에게 노출되면 때론 곤란해질수도 있다.


이미지 같은 정적파일들은 캐쉬로 보관되어 있으면 사이트 로딩등이 빨라지는 장점도 있지만, 

어떠한 액션이 있어야 하는 중요한 동적 페이지에서는 오히려 잘못된 결과를 초래하기도 한다.

캐쉬를 사용하지 않겠다고 하는 선언은 JSP 등과 같은 서버 사이드 언어나, html에 메타태그를 넣어 쉽게 적용이 가능하다.



- JSP의 경우 페이지 상단에 아래 구문을 넣으면 캐쉬가 적용되지 않는다.

<%
 response.setHeader("Cache-Control","no-cache");
 response.setHeader("Pragma","no-cache");
 response.setDateHeader("Expires",0);
%>



- HTML의 경우 아래 구문을 <head> 태그 사이에 넣어주면 된다.

<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Pragma" content="no-cache"/>



출처: http://fruitdev.tistory.com/103 [과일가게 개발자]

반응형
반응형



 left와 top 값을 0 으로 주시면 됩니다.





<script language=javascript>


function popConcert(){ 
   noticeWindow  = window.open('http://nibr.go.kr/exhibit/reserve_imsi/reserve_guide.jsp','bluesky','width=700,height=760,top=0,left=200,scrollbars=yes' );
noticeWindow.opener = self;
}
</script>


반응형
반응형

replace 사용하기 string 삭제


var dd = "2017.08"


.replace('삭제문자','변경할문자')

dd = dd.replace('.', ''); 


결과값 

dd ) 201708 로 된다

반응형

'프로그램 관련 > jquery&jsp&HTML' 카테고리의 다른 글

캐쉬 삭제하기  (0) 2018.08.22
팝업창 위치 설정  (0) 2018.08.20
select box disabled 하기 선택안되게하기  (0) 2018.08.16
table 엑셀 다운받기  (0) 2018.08.14
textarea , text글자제한 두기  (0) 2018.08.10
반응형

select box disabled 하기 선택안되게하기



네임 접근

$("select[name=네임]").attr("disabled", true);


ID접근

$("#아이디").attr("disabled", true);



다시 활성화 하고싶을시


$("#아이디").removeAttr("disabled"); 


하시면 됩니다^^

반응형
반응형

익스플로러가 안될수있습니다

        /*
        var targetObj = document.getElementById(targetId);
        var outputCss = targetObj.currentStyle;
        targetObj.style.backgroundColor = outputCss.getAttribute('background-color');
        targetObj.style.borderStyle = outputCss.getAttribute('border-style');
        targetObj.style.border = outputCss.getAttribute('border');
         */
 
        // 스타일 변경 수동 적용 가능
        var cssText = '<style type="text/css">';
        cssText += '.aaaa {font-size:11px; color:#333333; border:2px solid black; padding:10px 5px 8px 5px; background-color:#F3F5E0;}';
        cssText += '</style>';
 
        var output = document.getElementById(targetId).outerHTML;
 
        if (!SaveFileName) {
            SaveFileName = 'FilteredReport.xls';
        }
 
        var oWin = window.open("about:blank""_blank");
 
        oWin.document.write(cssText);
        oWin.document.write(output);
        oWin.document.close();
        // success = true, false
        var success = oWin.document.execCommand('SaveAs'false, SaveFileName);
        oWin.close();
 
        // **********************

        // 방법 2     

        // 방법 2   

        if (document.all.excelExportFrame == null// 프레임이 없으면 만들자~!
        {
            var excelFrame = document.createElement("iframe");
            excelFrame.id = "excelExportFrame";
            excelFrame.name = "excelExportFrame";
            excelFrame.position = "absolute";
            excelFrame.style.zIndex = -1;
            excelFrame.style.visibility = "hidden";
            excelFrame.style.top = "-10px";
            excelFrame.style.left = "-10px";
            excelFrame.style.height = "0px";
            excelFrame.style.width = "0px";
            document.body.appendChild(excelFrame); // 아이프레임을 현재 문서에 쑤셔넣고..
        }
        var frmTarget = document.all.excelExportFrame.contentWindow.document// 해당 아이프레임의 문서에 접근
 
        if (!SaveFileName) {
            SaveFileName = 'test.xls';
        }
 
        frmTarget.open("text/html""replace");
        frmTarget.write('<html>');
        frmTarget
                .write('<meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=euc-kr"/>\r\n'); // 별로..
        frmTarget.write('<body onload="saveFile();">');
        frmTarget.write(document.getElementById(targetId).outerHTML); // tag를 포함한 데이터를 쑤셔넣고
        frmTarget.write('<script language="javascript">');
        frmTarget
                .write('function saveFile(){document.execCommand("SaveAs", true, "'
                        + SaveFileName + '");}');
        frmTarget.write('<\/script>');
        frmTarget.write('</body>');
        frmTarget.write('</html>');
        frmTarget.close();
        //frmTarget.charset="UTF-8"; // 자 코드셋을 원하는걸로 맞추시고..
        frmTarget.charset = "euc-kr";
        frmTarget.focus();
 
    }
</script>





*테스트 하기
 
 
<h1>엑셀저장 테스트 </h1>
<br>
테이블만 저장 1 : <input type="button" value="excel" onclick="downloadExcel('tblMain')">
<br>
 
  <table border="1" id="tblMain" >
    <tr>
      <td rowspan="2">이름</td>
      <td>김호두</td>
      <td></td>
    </tr>
    <tr>
      <td colspan="2">김자두</td>
    </tr>
    <tr>
      <td rowspan="2">나이</td>
      <td colspan="2">20</td>
    </tr>
    <tr>
      <td>21</td>
      <td></td>
    </tr>
 
</table>
 



출처: http://cofs.tistory.com/17 [CofS]

반응형

+ Recent posts