Notice
Recent Posts
Recent Comments
Link
혜야의 코딩스토리
[JavaScript] 첨부파일 일괄 다운로드 (체크박스) 본문
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
</head>
<body>
<input type="checkbox" name="fieSeq" value="1001" />
<input type="checkbox" name="fieSeq" value="1002" />
<input type="checkbox" name="fieSeq" value="1003" />
<input type="checkbox" name="fieSeq" value="1004" />
<button onclick="javascript:suggestFileDownload();">다운로드</button>
<script>
var fileIdx = 0;
var fileCnt = 0;
function suggestFileDownload(){
if(jQuery('input[name=fieSeq]:checked').length == 0){
alert("다운받으실 제안을 선택해 주세요.");
return;
}
var oChk = document.getElementsByName("fieSeq")[fileIdx++];
if (oChk){
if (oChk.checked){
if(oChk.value != ""){
fileCnt++;
alert("# FILE DOWNLOAD : " + oChk.value);
//fileDownloadFunc(oChk.value, '25'); // 파일다운로드 실행함수
setTimeout(function(){suggestFileDownload()}, 1000);
}else{
suggestFileDownload();
}
}
else{
suggestFileDownload();
}
}else{
if(fileCnt == 0){
alert("다운로드할 파일이 없습니다.");
}else{
alert("다운로드가 완료되었습니다.");
}
}
}
</script>
</body>
</html>
'꿈 : 멋진 개발자 🧸 > JavaScript & jQuery' 카테고리의 다른 글
[jQuery] trigger() 함수 (0) | 2023.10.20 |
---|---|
[jQuery] 제이 쿼리(jQuery), Ajax(Asynchronous JavaScript And XML) (0) | 2022.07.17 |
[JavaScript] 문서 객체 모델(DOM, Document Object Model)과 이벤트 처리, 입력 검증 (0) | 2022.07.17 |
[JavaScript] 자바스크립트 (0) | 2022.07.17 |
[JavaScript] 자바스크립트로 간단한 계산기 만들기 (0) | 2022.06.27 |